/* Tip Platform — donation page stylesheet.
   No frameworks. No build step. Dark theme on the shared brand background.

   COLOR / SURFACE / GEOMETRY / TYPOGRAPHY TOKENS LIVE IN brand.css (loaded
   BEFORE this file by all templates). Do not redefine :root tokens here —
   per-brand accent and shared --font-* stacks come from brand.css. See
   AGENTS.md PINNED RULE #3 ("Central brand tokens are non-negotiable").
*/

* { box-sizing: border-box; }
:root {
  --top-bar-h: var(--brand-header-height);
}
html, body { margin: 0; padding: 0; }
html {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}
body {
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* Shared .top-bar / .brand / .brand-logo lockup lives in /static/brand.css.
   Keeping it centralized guarantees tip pages and aiplaysgames.com match. */

/* ---- Test-mode banner ---- */
.test-banner {
  background: var(--warn);
  color: var(--warn-fg);
  border-bottom: 1px solid color-mix(in srgb, var(--warn-fg) 30%, var(--warn));
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.test-banner code {
  background: color-mix(in srgb, var(--warn-fg) 14%, transparent);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
}

/* ---- Layout ---- */
.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: calc(var(--top-bar-h) + 16px) 20px 80px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .summary-col { position: static !important; }
}

.form-col > * + * { margin-top: 18px; }
/* Cards live inside the <form> inside .form-col, so the rule above doesn't
   reach them. Use flex+gap on the form itself for clean vertical stacking. */
.form-col form { display: flex; flex-direction: column; gap: 18px; }

/* ---- Live stream embed ---- */
.stream-embed {
  padding: 0;
  margin: 0;
}
.stream-head + .stream-embed {
  margin-top: 16px;
}
.stream-embed__player {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
  background: var(--bg-stream);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius);
}
/* Off-air color bars (same tokens as compact prompt) until embed loads or when offline. */
.stream-embed__player::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    90deg,
    var(--off-air-white) 0%,
    var(--off-air-white) 14.28%,
    var(--off-air-yellow) 14.28%,
    var(--off-air-yellow) 28.57%,
    var(--off-air-cyan) 28.57%,
    var(--off-air-cyan) 42.85%,
    var(--off-air-green) 42.85%,
    var(--off-air-green) 57.14%,
    var(--off-air-magenta) 57.14%,
    var(--off-air-magenta) 71.42%,
    var(--off-air-red) 71.42%,
    var(--off-air-red) 85.71%,
    var(--off-air-blue) 85.71%,
    var(--off-air-blue) 100%
  );
}
.stream-embed__player.is-off-air::before {
  opacity: 1;
  transition: opacity 360ms ease;
}
@media (prefers-reduced-motion: reduce) {
  .stream-embed__player.is-off-air::before {
    transition: none;
  }
}
.stream-embed__player.is-stream-offline iframe {
  visibility: hidden;
}
.stream-embed__player .stream-player__offline-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%);
  min-width: min(72%, 280px);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(11px, 2.8vw, 14px);
  letter-spacing: 0.12em;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 12%, transparent);
}
.stream-embed__player .stream-player__offline-badge[hidden] {
  display: none;
}
.stream-embed__player iframe {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.stream-embed__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 13px;
}
.stream-embed__platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft, var(--panel));
  border: 1px solid var(--panel-stroke, var(--hairline));
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.stream-embed__platform:hover {
  background: var(--panel-hover, var(--panel));
  border-color: var(--panel-stroke-strong, var(--hairline));
  text-decoration: none;
}

/* ---- Stream header ---- */
.stream-head {
  display: flex;
  gap: 14px;
  padding: 0 4px;
}
.stream-head__avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--panel-hover) 0%, var(--bg-grid) 100%);
  border: 1px solid var(--panel-stroke-strong);
  display: grid; place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stream-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.prompt-section-head {
  padding: 0 4px;
}
.prompt-section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.prompt-section-desc {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- Cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  margin: 0;
  min-width: 0;
}
/* Plain heading inside a .card. Replaces the legacy <legend> float trick,
   which broke fieldset height calculation on mobile and caused the cards
   below it to overlap. Now we use <section class="card"><h3 class="card__title">…
   See AGENTS.md for the donation page card pattern. */
.card__title {
  margin: 0 0 12px;
  padding: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  color: var(--text);
}
.card__title--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.muted { color: var(--text-muted); font-weight: 400; font-size: 13px; }
.giphy-powered {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}
.giphy-powered img {
  display: block;
  width: auto;
  height: 13px;
}

/* ---- Amount ---- */
.amount-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}
.amount-pill {
  --pill-accent: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 48px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-stroke);
  background: var(--pill-bg, var(--panel-2));
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
  user-select: none;
}
.amount-pill:hover { background: var(--pill-hover-bg, var(--panel-hover)); }
.amount-pill input { position: absolute; opacity: 0; pointer-events: none; }
.amount-pill span {
  position: relative;
  z-index: 1;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  color: var(--text);
}
.amount-pill.is-active {
  border-color: var(--pill-accent);
  background: color-mix(in srgb, var(--pill-accent) 10%, var(--panel-2));
  box-shadow: 0 0 0 1px var(--pill-accent) inset;
}
.amount-pill.is-active span { color: var(--pill-accent); }

.field { display: block; }
.field__label {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field--currency {
  position: relative;
}
.field--currency::before {
  content: "$";
  position: absolute;
  left: 12px;
  bottom: 0;
  height: 44px;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
}
.card .field--currency input[type="text"] {
  height: 44px;
  margin-top: 0;
  padding: 0 12px 0 30px;
  line-height: 1.2;
}

/* ---- Text/search inputs & textareas ---- */
.card input[type="text"],
.card input[type="search"],
.card textarea {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  margin-top: 10px;
  outline: none;
  resize: vertical;
}
.card input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
.card input[type="search"]::-webkit-search-cancel-button,
.card input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.card input[type="text"]:focus,
.card input[type="search"]:focus,
.card textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--panel-stroke));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.card > .card__title + input[type="text"],
.card > .card__title + textarea {
  margin-top: 0;
}
.char-counter {
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---- Model picker (multi-agent shows) ---- */
.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.model-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.model-card:hover { background: var(--panel-hover); }
.model-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.model-card__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.model-card__label {
  font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 0.5em;
}
.model-card__desc {
  font-size: 12px; color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.model-card__check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--panel-stroke-strong);
  flex-shrink: 0;
  position: relative;
  transition: all 120ms ease;
}
.model-card.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-2));
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.model-card.is-active .model-card__check {
  background: var(--accent);
  border-color: var(--accent);
}
.model-card.is-active .model-card__check::after {
  /* Checkmark stroke painted via mask-image so the color follows
     --accent-ink per brand (dark slate on US green, white on CN red).
     CSS variables can't be substituted inside data: URLs, so we use the
     same mask-image trick as .brand-icon in brand.css. */
  content: "";
  position: absolute;
  inset: 0;
  color: var(--accent-ink);
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.5l2.5 2.5 4.5-5'/></svg>") center / 70% no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.5l2.5 2.5 4.5-5'/></svg>") center / 70% no-repeat;
}

/* ---- Voice grid ---- */
.disable-tts {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 13px; font-weight: 400;
  cursor: pointer;
}
.disable-tts input { accent-color: var(--accent); }

/* Cap the voice list height so a card with 12+ voices stops growing the
   form-column past the viewport — the donor scrolls inside the card.
   ~clamp(280px, 50vh, 420px) gives ~3-5 rows visible depending on the
   viewport, which on a desktop 1080p screen lands at the natural sweet
   spot (the rest of the form stays visible above and below). */
.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
  max-height: clamp(280px, 50vh, 420px);
  overflow-y: auto;
  padding-right: 0;
}
.voice-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 10px;
  background: var(--panel-2);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.voice-card:hover { background: var(--panel-hover); }
.voice-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.voice-card__preview {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--panel-stroke-strong);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 120ms ease, border-color 120ms ease;
}
.voice-card__preview:hover {
  background: var(--bg-grid);
  border-color: var(--accent);
}
/* The button keeps three SVGs in the DOM and swaps the visible one by
   data-state ("idle" | "loading" | "playing"). All three sit at the
   same 16×16 px box so the button doesn't resize between states. */
.voice-card__preview[data-state="playing"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.voice-card__preview[data-state="loading"] {
  border-color: var(--accent);
  color: var(--accent);
}
.voice-card__icon {
  display: none;
  width: 16px;
  height: 16px;
  fill: currentColor;
  pointer-events: none;
}
.voice-card__preview[data-state="idle"] .voice-card__icon--play,
.voice-card__preview[data-state="loading"] .voice-card__icon--loading,
.voice-card__preview[data-state="playing"] .voice-card__icon--pause {
  display: block;
}
.voice-card__icon--play {
  /* Visually center the play triangle — its bbox sits ~0.5 px left of
     the geometric center because the leading edge is vertical. */
  transform: translateX(0.5px);
}
.voice-card__preview[data-state="loading"] .voice-card__icon--loading {
  animation: voice-spin 0.9s linear infinite;
}
@keyframes voice-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .voice-card__preview[data-state="loading"] .voice-card__icon--loading {
    animation: none;
    opacity: 0.7;
  }
}
.voice-card__meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.voice-card__label { font-size: 14px; font-weight: 600; color: var(--text); }
.voice-card__desc {
  font-size: 12px; color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}
.voice-card__check {
  width: 18px; height: 18px; border-radius: var(--radius-xs);
  border: 1px solid var(--panel-stroke-strong);
  flex-shrink: 0;
  position: relative;
  transition: all 120ms ease;
}
.voice-card.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-2));
}
.voice-card.is-active .voice-card__check {
  background: var(--accent);
  border-color: var(--accent);
}
.voice-card.is-active .voice-card__check::after {
  /* Same per-brand checkmark trick as .model-card.is-active above. */
  content: "";
  position: absolute;
  inset: 0;
  color: var(--accent-ink);
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.5l2.5 2.5 4.5-5'/></svg>") center / 70% no-repeat;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.5l2.5 2.5 4.5-5'/></svg>") center / 70% no-repeat;
}

/* ---- Right column ---- */
.summary-col {
  position: sticky; top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.summary h2, .checkout h2 {
  margin: 0 0 12px;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.summary dl { margin: 0; }
.summary dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--panel-stroke);
  font-size: 14px;
}
.summary dl > div:first-child { border-top: 0; padding-top: 0; }
.summary dt { color: var(--text-muted); flex: 0 0 auto; }
.summary dd {
  min-width: 0;
  max-width: 60%;
  margin: 0;
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0 0 10px;
}
.disclaimer strong, .disclaimer em { color: var(--text); }
.disclaimer a { color: var(--accent); font-weight: 600; }

.checkout-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: filter 120ms ease, transform 120ms ease;
}
.checkout-btn:hover:not(:disabled) { filter: brightness(1.08); }
.checkout-btn:active:not(:disabled) { transform: translateY(1px); }
.checkout-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.checkout-error {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 60%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* "Powered by Stripe" trust footer — wordmark + mark, centered, with
   a hairline seam separating it from the CTA above. Trimmed from the
   earlier wordmark + Visa/MC/Apple/Google/Alipay/WeChat line because
   the card list was visual clutter — Stripe alone is the trust
   signal donors recognize. Single-row layout means no flex column;
   we center via text-align so the inline-block wordmark sits in the
   middle of the seam. */
.pay-logos {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-stroke);
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.pay-logos__stripe {
  display: inline-block;
  font-weight: 400;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pay-logos__stripe-mark {
  display: inline-block;
  height: 14.3px;
  width: calc(14.3px * 360.02 / 149.84);
  margin-left: 5px;
  vertical-align: -4.4px;
  background-color: var(--stripe-brand);
  -webkit-mask-image: url("/static/stripe-logo.svg?v=gray-20260517");
  mask-image: url("/static/stripe-logo.svg?v=gray-20260517");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
}

/* ---- Thanks page ---- */
.thanks-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.thanks-panel {
  max-width: 480px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius);
  padding: 36px 28px;
}
.thanks-check {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  margin: 0 auto 18px;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 700;
}
.thanks-panel h1 { margin: 0 0 8px; font-size: 22px; }
.thanks-panel p { margin: 6px 0; color: var(--text-muted); }
.thanks-panel a { color: var(--accent); }

/* ---- Terms page ---- */
.terms-body {
  min-height: 100vh;
  padding: calc(var(--top-bar-h) + 32px) 20px 80px;
}
.terms-page {
  max-width: 820px;
  margin: 0 auto;
}
.terms-page h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.02em;
}
.terms-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.terms-meta {
  margin: 0 0 24px;
  color: var(--text-muted);
}
.terms-section {
  border-top: 1px solid var(--panel-stroke);
  padding-top: 18px;
  margin-top: 18px;
}
.terms-section h2 {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.terms-section p {
  margin: 8px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}
.terms-back {
  border-top: 1px solid var(--panel-stroke);
  margin: 24px 0 0;
  padding-top: 18px;
}
.terms-back a { color: var(--accent); font-weight: 700; }

/* ── Image picker — compact preview + modal picker ─────────────────
   The card only previews four images on mobile. The full local pool and
   GIPHY search live in the modal so thumbnails keep their aspect ratio. */

.image-picker-actions {
  display: block;
  gap: 8px;
  margin-top: 12px;
}

.image-action {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.image-action:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
}

.giphy-quick-search {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  gap: 8px;
}
.giphy-quick-search input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 40px;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.2;
  margin-top: 0;
}
.giphy-quick-search .image-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  min-height: 0;
  line-height: 1;
  padding: 0;
  white-space: nowrap;
}
.giphy-search-button__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.giphy-search {
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
}
.giphy-search__label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.giphy-search__row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.giphy-search__row input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 40px;
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.2;
  margin-top: 0;
}
.giphy-search__row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--text);
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.giphy-search__row button:hover:not(:disabled) {
  background: var(--panel-hover);
  border-color: var(--accent);
}
.giphy-search__row button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.giphy-search__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 11px;
}
.giphy-search__meta[hidden] {
  display: none;
}
.giphy-attribution {
  margin-left: auto;
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.image-preview-grid {
  /* Single on-page preview slot for the currently-selected GIF. The
     multi-cell selector grid was retired 2026-05-22 — donors browse or
     search for GIFs in the modal; this slot just shows what they (or the
     server-seeded default) picked. We keep `display: grid` so the
     existing .image-cell aspect-ratio sizing applies cleanly; the column
     track is capped at 200px so the cell stays a sensible fixed size on
     wide cards. */
  display: grid;
  grid-template-columns: minmax(120px, 200px);
  justify-content: start;
  gap: 8px;
  margin-top: 12px;
}
.image-preview-grid[hidden] {
  display: none;
}
.image-browse-actions {
  margin-top: 10px;
}
.image-browse-actions .image-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  line-height: 1;
}
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  margin-top: 12px;
  max-height: clamp(220px, 38vh, 360px);
  overflow-y: auto;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-sm);
}
.image-grid[hidden] {
  display: none;
}
.image-grid--giphy {
  max-height: clamp(128px, 24vh, 220px);
}
.image-grid--modal {
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  max-height: none;
  overflow: visible;
}
.image-cell {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: var(--panel-2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 100ms ease, transform 100ms ease;
}
.image-cell:hover { border-color: var(--panel-stroke-strong); }
.image-cell:hover img { transform: scale(1.05); }
.image-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 200ms ease;
}
.image-cell.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.image-cell__check {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.image-cell__check::before { content: "✓"; }
.image-cell.is-active .image-cell__check { display: flex; }
/* Modal picker closes on pick — selection shows in the on-page preview only */
.image-modal .image-cell .image-cell__check {
  display: none;
}

body.image-modal-open {
  overflow: hidden;
}
.image-modal {
  --image-modal-edge-gap: 8px;
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: calc(var(--top-bar-h) + var(--image-modal-edge-gap)) minmax(0, 1fr);
  justify-items: center;
  padding: 0 14px var(--image-modal-edge-gap);
}
.image-modal[hidden] {
  display: none;
}
.image-modal__scrim {
  position: absolute;
  top: var(--top-bar-h);
  right: 0;
  bottom: 0;
  left: 0;
  border: 0;
  background: color-mix(in srgb, var(--shadow-ink) 72%, transparent);
  cursor: pointer;
}
.image-modal__panel {
  position: relative;
  grid-row: 2;
  align-self: center;
  justify-self: center;
  width: min(720px, 100%);
  max-height: min(760px, calc(100dvh - var(--top-bar-h) - (var(--image-modal-edge-gap) * 2)));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--panel-stroke-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px color-mix(in srgb, var(--shadow-ink) 70%, transparent);
}
.image-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--panel-stroke);
}
.image-modal__heading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.image-modal__header h4 {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 0;
  font-size: 18px;
  line-height: 1;
}
.image-modal__back {
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  color: var(--text);
  width: 34px;
  height: 34px;
  padding: 0;
  line-height: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.image-modal__back:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
}
.image-modal__back svg {
  width: 16px;
  height: 16px;
}
.image-modal__header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
.image-modal__close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius-pill);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font: inherit;
  line-height: 0;
  padding: 0;
}
.image-modal__close svg {
  display: block;
  width: 16px;
  height: 16px;
}
.image-modal__close:hover {
  background: var(--panel-hover);
  border-color: var(--accent);
}
.image-modal__search {
  flex: 0 0 auto;
  margin: 0 16px 12px;
}
.image-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 16px;
}
.voice-grid,
.image-grid,
.image-modal__body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.voice-grid::-webkit-scrollbar,
.image-grid::-webkit-scrollbar,
.image-modal__body::-webkit-scrollbar {
  display: none;
}
.image-modal__section-title {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.06em;
}
.image-category-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.image-category-cards[hidden] {
  display: none;
}
.image-category-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  aspect-ratio: 2.15 / 1;
  padding: 0;
  border: 1px solid var(--panel-stroke);
  border-radius: var(--radius);
  background-color: var(--panel-2);
  background-size: cover;
  background-position: center;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 120ms ease, transform 120ms ease;
}
.image-category-card:hover {
  border-color: var(--panel-stroke-strong);
}
.image-category-card:active {
  transform: scale(0.995);
}
.image-category-card__cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-category-card.image-category-card--cover-missing {
  background-color: var(--bg);
}
.image-category-card.image-category-card--cover-missing .image-category-card__cover {
  display: none;
}
.image-category-card__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--shadow-ink) 30%, transparent),
    color-mix(in srgb, var(--shadow-ink) 72%, transparent)
  );
}
.image-category-card__label {
  position: relative;
  z-index: 1;
  padding: 0 10px;
  font-family: var(--font-ui);
  font-size: 29px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.image-category {
  margin-top: 12px;
}
.image-category[hidden] {
  display: none;
}
.image-category__title {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}
.image-modal[data-view="category"] .image-category__title {
  display: none;
}
.image-modal[data-view="search"] .image-category-cards {
  display: none;
}
.image-modal[data-view="search"] .image-category {
  display: none;
}
.image-modal .image-grid {
  margin-top: 10px;
}
.image-modal .image-grid--giphy {
  max-height: none;
}

@media (max-width: 560px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
  .amount-pill[data-amount="25"] {
    display: none;
  }
  .stream-embed__meta {
    gap: 16px;
    flex-wrap: wrap;
  }
  .giphy-quick-search {
    gap: 6px;
  }
  .image-preview-grid {
    gap: 6px;
  }
  .voice-grid {
    max-height: clamp(180px, 32vh, 260px);
  }
  .image-grid--modal {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .image-category-cards {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .image-category-card__label {
    font-size: 24px;
  }
  .image-modal {
    padding: 0 10px var(--image-modal-edge-gap);
  }
  .image-modal__panel {
    align-self: end;
    max-height: calc(100dvh - var(--top-bar-h) - (var(--image-modal-edge-gap) * 2));
  }
}
