/* PolitiSizeIt Campaign Studio
   Dark-first by design: this is an app surface, not a document. Deliberately
   non-partisan palette — indigo/cyan rather than red/blue. */

:root {
  --bg: #08090d;
  --surface: rgba(255, 255, 255, 0.038);
  --surface-2: rgba(255, 255, 255, 0.065);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ecf3;
  --text-dim: #9aa3b8;
  --text-faint: #6b7488;
  --accent: #7c8cff;
  --accent-2: #34d8f0;
  --accent-glow: rgba(124, 140, 255, 0.35);
  --danger: #ff8b8b;
  --ok: #4ade80;

  --radius: 16px;
  --radius-lg: 22px;
  --maxw: 760px;
  --ease: cubic-bezier(0.22, 0.9, 0.3, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- ambient background ------------------------------------------------ */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 12% -10%, rgba(124, 140, 255, 0.16), transparent 60%),
    radial-gradient(50rem 34rem at 92% 8%, rgba(52, 216, 240, 0.10), transparent 62%),
    radial-gradient(40rem 40rem at 50% 108%, rgba(124, 140, 255, 0.09), transparent 60%);
}
.ambient::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(70% 60% at 50% 30%, #000 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 30%, #000 0%, transparent 100%);
}

/* --- top bar ----------------------------------------------------------- */

.topbar {
  position: relative;
  z-index: 2;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 20px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 13, 0.72);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.mark {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.12), 0 6px 18px -6px var(--accent-glow);
  position: relative;
}
.mark::after {
  content: '';
  position: absolute;
  inset: 7px 7px auto 7px;
  height: 3px;
  border-radius: 2px;
  background: rgba(8, 9, 13, 0.75);
  box-shadow: 0 5px 0 rgba(8, 9, 13, 0.75), 0 10px 0 rgba(8, 9, 13, 0.55);
}

.brand-text {
  font-weight: 620;
  letter-spacing: -0.015em;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-size: 15px;
}
.brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ghost-btn {
  flex: none;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 16px;
  min-height: 44px;
  cursor: pointer;
  transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.ghost-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }

/* --- stage / scroll ---------------------------------------------------- */

.stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding: 0 20px;
}

/* --- intro ------------------------------------------------------------- */

.intro {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(36px, 9vh, 88px) 0 40px;
  animation: rise .7s var(--ease) both;
}

.headline {
  margin: 0 0 18px;
  font-size: clamp(30px, 7.2vw, 50px);
  line-height: 1.08;
  letter-spacing: -0.032em;
  font-weight: 660;
}
.headline em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: 0 0 34px;
  max-width: 56ch;
  color: var(--text-dim);
  font-size: clamp(15px, 3.6vw, 17px);
  line-height: 1.65;
}
.sub strong { color: var(--text); font-weight: 600; }

.suggestions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 520px) {
  /* Two columns keeps the four cards as a balanced 2x2 rather than an orphaned row. */
  .suggestions { grid-template-columns: repeat(2, 1fr); }
}

.suggestion {
  font: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.suggestion::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(124, 140, 255, 0.10), transparent);
  opacity: 0;
  transition: opacity .25s var(--ease);
}
.suggestion:hover { transform: translateY(-2px); border-color: var(--line-strong); background: var(--surface-2); }
.suggestion:hover::before { opacity: 1; }
.s-title { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; position: relative; }
.s-body { font-size: 13px; color: var(--text-faint); line-height: 1.45; position: relative; }

/* --- thread ------------------------------------------------------------ */

.thread {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 0 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.thread:empty { display: none; }

.msg { animation: rise .45s var(--ease) both; }

.msg-user {
  align-self: flex-end;
  max-width: 85%;
  background: linear-gradient(135deg, rgba(124, 140, 255, 0.20), rgba(52, 216, 240, 0.13));
  border: 1px solid rgba(124, 140, 255, 0.28);
  padding: 12px 16px;
  border-radius: var(--radius-lg) var(--radius-lg) 6px var(--radius-lg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15.5px;
}

.msg-ai { display: flex; gap: 13px; }

.avatar {
  flex: none;
  width: 25px; height: 25px;
  margin-top: 2px;
  border-radius: 7px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1);
}

.msg-body {
  min-width: 0;
  flex: 1;
  font-size: 15.8px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}
.msg-body p { margin: 0 0 0.85em; }
.msg-body p:last-child { margin-bottom: 0; }
.msg-body strong { font-weight: 620; color: #fff; }
.msg-body em { font-style: italic; color: var(--text-dim); }
.msg-body ul, .msg-body ol { margin: 0.5em 0 0.85em; padding-left: 1.25em; }
.msg-body li { margin: 0.25em 0; }
.msg-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

/* streaming caret */
.caret {
  display: inline-block;
  width: 2px; height: 1.05em;
  vertical-align: -0.16em;
  margin-left: 2px;
  background: var(--accent-2);
  border-radius: 1px;
  animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink { 0%, 50% { opacity: 1 } 50.01%, 100% { opacity: 0 } }

/* --- tool activity ----------------------------------------------------- */

.tool-log:not(:empty) { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tool-log .tool-chip { margin-bottom: 0; }
/* Once the answer is written the chips are history, not live activity. */
.tool-log .tool-chip .dot { animation: none; opacity: .55; }
.tool-chip:last-child .dot { animation: pulse 1.3s ease-in-out infinite; opacity: 1; }

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px 5px 10px;
  margin-bottom: 10px;
  animation: rise .35s var(--ease) both;
}
.tool-chip .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
  animation: pulse 1.3s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .4; transform: scale(.8) } 50% { opacity: 1; transform: scale(1.15) } }

.thinking {
  display: inline-flex;
  gap: 5px;
  padding: 6px 0;
}
.thinking span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: bounce 1.3s var(--ease) infinite;
}
.thinking span:nth-child(2) { animation-delay: .16s }
.thinking span:nth-child(3) { animation-delay: .32s }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45 } 30% { transform: translateY(-5px); opacity: 1 } }

/* --- brief complete card ----------------------------------------------- */

.brief-card {
  border: 1px solid rgba(124, 140, 255, 0.32);
  background: linear-gradient(150deg, rgba(124, 140, 255, 0.11), rgba(52, 216, 240, 0.06));
  border-radius: var(--radius-lg);
  padding: 22px;
  animation: rise .5s var(--ease) both;
}
.brief-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: 9px;
}
.brief-card h3::before {
  content: '';
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.5);
  flex: none;
}
.brief-card p { margin: 0 0 16px; color: var(--text-dim); font-size: 14.5px; }
.brief-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text-faint);
}

.cta {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #0a0b10;
  background: linear-gradient(135deg, #fff, #d7dcf5);
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
  box-shadow: 0 8px 24px -10px rgba(255, 255, 255, 0.4);
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -10px rgba(255, 255, 255, 0.5); }

.sys-note {
  font-size: 13.5px;
  color: var(--danger);
  border: 1px solid rgba(255, 139, 139, 0.28);
  background: rgba(255, 139, 139, 0.07);
  border-radius: 12px;
  padding: 11px 14px;
}

/* --- composer ---------------------------------------------------------- */

.composer-wrap {
  position: relative;
  z-index: 2;
  flex: none;
  padding: 12px 20px calc(var(--safe-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}

.composer {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 9px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 7px 7px 7px 16px;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.composer:focus-within {
  border-color: rgba(124, 140, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(124, 140, 255, 0.10);
}

#input {
  flex: 1;
  font: inherit;
  /* 16px minimum prevents iOS Safari from zooming the viewport on focus */
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  resize: none;
  max-height: 180px;
  padding: 11px 0;
  min-height: 44px;
}
#input::placeholder { color: var(--text-faint); }

.send {
  flex: none;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 12px;
  color: #0a0b10;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.send:hover:not(:disabled) { transform: scale(1.05); }
.send:disabled { opacity: .32; cursor: default; }

.disclaimer {
  max-width: var(--maxw);
  margin: 9px auto 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-faint);
}

/* --- payment sheet ----------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(4, 5, 8, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade .25s var(--ease) both;
}

.sheet {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(460px, 100%);
  background: #101219;
  border: 1px solid var(--line-strong);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 26px 24px calc(var(--safe-bottom) + 26px);
  animation: sheet-up .34s var(--ease) both;
}
@media (min-width: 560px) {
  .sheet {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 24px;
    border-bottom: 1px solid var(--line-strong);
    /* Must not use `rise` here: its `transform: none` endpoint would cancel the
       centering translate and shove the dialog off-centre. */
    animation: sheet-in .3s var(--ease) both;
  }
}

.sheet-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 44px; height: 44px;
  font-size: 24px;
  line-height: 1;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
}
.sheet-close:hover { color: var(--text); background: var(--surface); }

.sheet h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.02em; }
.sheet-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }

.amount-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }

.amount {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .18s var(--ease);
}
.amount:hover { border-color: var(--line-strong); }
.amount[aria-pressed="true"] {
  border-color: var(--accent);
  background: rgba(124, 140, 255, 0.16);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.12);
}

.custom-amount { display: block; margin-bottom: 16px; }
.custom-amount > span { display: block; font-size: 12.5px; color: var(--text-faint); margin-bottom: 6px; }
.input-money {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--text-faint);
}
.input-money:focus-within { border-color: rgba(124, 140, 255, 0.55); }
#custom-amount {
  flex: 1;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  padding: 12px 0;
}

.pay-error { margin: 0 0 12px; font-size: 13.5px; color: var(--danger); }

.pay-btn {
  width: 100%;
  font: inherit;
  font-size: 16px;
  font-weight: 620;
  color: #0a0b10;
  background: linear-gradient(135deg, #fff, #dfe3f7);
  border: none;
  border-radius: 14px;
  padding: 15px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform .18s var(--ease);
}
.pay-btn:hover:not(:disabled) { transform: translateY(-1px); }
.pay-btn:disabled { opacity: .5; cursor: default; }
.pay-btn-amount { opacity: .55; font-variant-numeric: tabular-nums; }

.pay-note { margin: 14px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-faint); text-align: center; }
.pay-note strong { color: var(--text-dim); }

/* --- motion ------------------------------------------------------------ */

@keyframes rise { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheet-up { from { transform: translate(-50%, 100%) } to { transform: translate(-50%, 0) } }
@keyframes sheet-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)) }
  to   { opacity: 1; transform: translate(-50%, -50%) }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

::-webkit-scrollbar { width: 9px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 5px; border: 2px solid transparent; background-clip: content-box }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); background-clip: content-box }

/* --- audience count card ------------------------------------------------ */

.count-card {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  animation: rise .45s var(--ease) both;
}
.count-card.done { border-color: rgba(74, 222, 128, .35); background: rgba(74, 222, 128, .06); }
.count-card.failed { border-color: rgba(255, 139, 139, .3); background: rgba(255, 139, 139, .05); }

.count-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.count-label {
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.count-spinner {
  width: 13px; height: 13px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent-2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

.count-value {
  font-size: clamp(22px, 5vw, 30px);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.count-card.done .count-value {
  background: linear-gradient(100deg, var(--accent) 10%, var(--accent-2) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.count-card:not(.done) .count-value { font-size: 15px; font-weight: 500; color: var(--text-dim); }

.count-note { margin-top: 7px; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }


/* --- preview banner ------------------------------------------------------
   Content is derived from /api/config, so it disappears by itself once live
   counting and live payments are switched on. */

.preview-banner {
  position: relative;
  z-index: 2;
  flex: none;
  border-bottom: 1px solid rgba(252, 211, 77, .22);
  background: rgba(252, 211, 77, .07);
}
.preview-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: #f6d98a;
}
.preview-tag {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(252, 211, 77, .35);
  color: #fcd34d;
}
#preview-text { flex: 1; min-width: 0; }
.preview-close {
  flex: none;
  width: 30px; height: 30px;
  font-size: 20px;
  line-height: 1;
  color: #f6d98a;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  opacity: .7;
}
.preview-close:hover { opacity: 1; background: rgba(252, 211, 77, .1); }

@media (max-width: 560px) {
  .preview-inner { align-items: flex-start; }
  .preview-tag { margin-top: 1px; }
}
