:root {
  --chat-bg: #06100b;
  --chat-surface: #0b1710;
  --chat-surface-soft: #112019;
  --chat-line: rgba(255, 255, 255, 0.11);
  --chat-text: #f3f5ef;
  --chat-muted: #98a39b;
  --chat-lime: #c8f548;
  --chat-mint: #7cefd1;
}
html,
body.chat-app-page {
  height: 100%;
}

body.chat-app-page {
  min-width: 320px;
  margin: 0;
  overflow: hidden;
  background: var(--chat-bg);
  color: var(--chat-text);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.chat-app-page * {
  box-sizing: border-box;
}

.chat-app-page .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.chat-app-page button,
.chat-app-page textarea {
  font: inherit;
}

.chat-app-header {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--chat-line);
  background: rgba(6, 16, 11, 0.94);
  backdrop-filter: blur(18px);
}

.chat-app-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  justify-self: start;
  color: var(--chat-text);
  text-decoration: none;
}

.chat-app-brand > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(200, 245, 72, 0.55);
  border-radius: 9px;
  color: var(--chat-lime);
  font-size: 13px;
  font-weight: 900;
}

.chat-app-brand strong {
  font-size: 14px;
}

.chat-app-title {
  margin: 0;
  color: #dbe1da;
  line-height: 1;
  font-size: 13px;
  font-weight: 700;
}

.chat-app-close {
  display: grid;
  place-items: center;
  justify-self: end;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #c8d0c9;
  font-size: 24px;
  line-height: 1;
  text-decoration: none;
}

.chat-app-close:hover {
  background: rgba(255, 255, 255, 0.07);
  color: white;
}

.chat-app {
  height: calc(100dvh - 58px);
  margin-top: 58px;
}

.conversation-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  width: min(820px, 100%);
  height: 100%;
  margin: 0 auto;
  background: var(--chat-bg);
}

.conversation-log {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 18px;
  padding: 28px 20px 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: rgba(200, 245, 72, 0.28) transparent;
}

.conversation-message {
  display: flex;
  max-width: min(78%, 610px);
  animation: chat-message-in 180ms ease both;
}

.conversation-message[data-role="user"] {
  align-self: flex-end;
}

.conversation-avatar {
  display: none;
}

.conversation-bubble {
  padding: 11px 15px;
  border: 1px solid var(--chat-line);
  border-radius: 18px 18px 18px 5px;
  background: var(--chat-surface-soft);
  color: #ecf0e9;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.conversation-message[data-role="user"] .conversation-bubble {
  border-color: rgba(200, 245, 72, 0.26);
  border-radius: 18px 18px 5px 18px;
  background: rgba(166, 207, 54, 0.16);
  color: #f7f9f1;
}

.conversation-thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  width: min(820px, 100%);
  padding: 0 22px 10px;
}

.conversation-thinking[hidden] {
  display: none;
}

.conversation-thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-muted);
  animation: chat-dot 1s ease-in-out infinite;
}

.conversation-thinking span:nth-child(2) { animation-delay: 120ms; }
.conversation-thinking span:nth-child(3) { animation-delay: 240ms; }

.chat-composer-form {
  position: relative;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--chat-line);
  background: linear-gradient(180deg, rgba(6, 16, 11, 0.84), #06100b 35%);
}

body.chatgpt-handoff-review {
  overflow: auto;
}

.chatgpt-handoff-review .chat-app {
  height: auto;
  min-height: calc(100dvh - 58px);
}

.chatgpt-handoff-review .conversation-panel {
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: calc(100dvh - 58px);
  height: auto;
}

.chatgpt-handoff-review .conversation-log {
  justify-content: center;
  overflow: visible;
  padding-block: clamp(24px, 6vh, 64px);
}

.chatgpt-handoff-review .chat-composer-form[data-handoff-review="true"] {
  padding: 0 20px 24px;
  border-top: 0;
  background: transparent;
}

.chatgpt-handoff-review .chat-composer-form[data-handoff-review="true"] .composer-status:empty {
  display: none;
}

.chatgpt-handoff-review [data-revise-card],
.chatgpt-handoff-review [data-ai-handoff],
.chatgpt-handoff-review .conversation-thinking {
  display: none !important;
}

.chatgpt-handoff-review .image-generation-status {
  display: none;
}

.chatgpt-handoff-review .conversation-draft {
  width: min(720px, 100%);
  margin: 0 auto;
  animation: chatgpt-review-in 220ms ease-out both;
}

.chat-composer-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px 42px;
  align-items: end;
  gap: 5px;
  max-width: 780px;
  margin: 0 auto;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  background: #101c15;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
}

.chat-composer-input-wrap:focus-within {
  border-color: rgba(200, 245, 72, 0.48);
  box-shadow: 0 0 0 3px rgba(200, 245, 72, 0.06), 0 14px 36px rgba(0, 0, 0, 0.24);
}

.chat-app-page #bounty-composer-input {
  width: 100%;
  min-height: 42px;
  max-height: 160px;
  margin: 0;
  padding: 10px 11px 8px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--chat-text);
  font-size: 15px;
  line-height: 1.45;
}

.chat-app-page #bounty-composer-input:focus {
  border: 0;
  box-shadow: none;
}

.chat-app-page #bounty-composer-input::placeholder {
  color: #7f8a82;
}

.chat-composer-input-wrap .composer-mic,
.chat-send {
  position: static;
  display: grid;
  place-items: center;
  align-self: end;
  border: 0;
  cursor: pointer;
}

.chat-composer-input-wrap .composer-mic {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  color: #9aa69d;
}

.chat-composer-input-wrap .composer-mic:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.chat-composer-input-wrap .composer-mic svg,
.chat-send svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--chat-lime);
  color: #0a1208;
}

.chat-send:hover {
  transform: scale(1.04);
}

.chat-send:disabled,
.composer-mic:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.composer-status {
  display: block;
  max-width: 780px;
  min-height: 0;
  margin: 7px auto 0;
  padding: 0 8px;
  color: #9aa69d;
  font-size: 11px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.composer-status:empty {
  display: none;
}

.composer-status[data-tone="error"] { color: #ff9f92; }
.composer-status[data-tone="pending"] { color: var(--chat-mint); }
.composer-status[data-tone="success"] { color: var(--chat-lime); }

.conversation-draft {
  align-self: flex-start;
  width: min(100%, 680px);
  margin: 0;
  border: 0;
  background: transparent;
}

.conversation-draft[hidden] {
  display: none;
}

.conversation-draft .bounty-card {
  display: block;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(200, 245, 72, 0.28);
  border-radius: 20px;
  background: #0b1810;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.conversation-draft .bounty-card-visual {
  position: relative;
  height: 190px;
  overflow: hidden;
}

.conversation-draft .bounty-card-visual canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.conversation-draft .bounty-card-badge,
.conversation-draft .image-generation-status {
  position: absolute;
  top: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(4, 13, 8, 0.74);
  color: #e7ede5;
  font-size: 10px;
  font-weight: 750;
  backdrop-filter: blur(10px);
}

.conversation-draft .bounty-card-badge { left: 12px; }
.conversation-draft .image-generation-status { right: 12px; }

.conversation-draft .bounty-card-body {
  padding: 20px;
}

.draft-card-heading {
  margin-bottom: 16px;
}

.draft-state {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--chat-mint);
  font-size: 11px;
  font-weight: 800;
}

.draft-state[data-tone="approved"] {
  color: var(--chat-lime);
}

.conversation-draft h2 {
  margin: 0;
  color: var(--chat-text);
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.conversation-draft .bounty-card-goal {
  margin: 9px 0 0;
  color: #b8c2ba;
  font-size: 14px;
  line-height: 1.5;
}

.conversation-draft .bounty-card-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}

.conversation-draft .bounty-stat {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.conversation-draft .bounty-stat span,
.conversation-draft .bounty-stat strong {
  display: block;
}

.conversation-draft .bounty-stat span {
  margin-bottom: 4px;
  color: #829087;
  font-size: 10px;
  text-transform: uppercase;
}

.conversation-draft .bounty-stat strong {
  color: #f2f5ef;
  font-size: 13px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.done-when {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.done-when h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.done-when ol {
  margin: 0;
  padding-left: 20px;
  color: #c8d0c9;
  font-size: 13px;
  line-height: 1.5;
}

.done-when li + li {
  margin-top: 5px;
}

.bounty-review-details,
.mission-context {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #aab5ad;
  font-size: 12px;
}

.bounty-review-details summary,
.mission-context summary {
  color: #dce2dc;
  cursor: pointer;
  font-weight: 700;
}

.bounty-review-details ul {
  padding-left: 18px;
  line-height: 1.5;
}

.bounty-review-details p,
.mission-context p {
  line-height: 1.5;
}

.mission-horizon {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--chat-lime);
}

.mission-task-options {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.mission-task-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  cursor: pointer;
}

.mission-task-option small {
  display: block;
  margin-top: 3px;
  color: #86938a;
}

.chat-draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.chat-draft-actions .button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
}

.chat-draft-actions [data-open-funding] {
  margin-left: auto;
}

.chat-wallet-dialog {
  width: min(520px, calc(100% - 24px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  overflow: auto;
  border: 1px solid rgba(200, 245, 72, 0.28);
  border-radius: 20px;
  background: #0a1710;
  color: var(--chat-text);
}

.chat-wallet-dialog::backdrop {
  background: rgba(0, 5, 3, 0.72);
  backdrop-filter: blur(5px);
}

.chat-wallet-dialog .payment-dialog-inner {
  padding: 20px;
}

.chat-wallet-dialog .payment-dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.chat-wallet-dialog .payment-dialog-head h2,
.chat-wallet-dialog .payment-dialog-head p {
  margin: 0;
}

.chat-wallet-dialog .payment-dialog-head p {
  margin-top: 4px;
  color: var(--chat-muted);
  font-size: 12px;
}

.chat-wallet-dialog .dialog-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  cursor: pointer;
  font-size: 22px;
}

.wallet-options {
  display: grid;
  gap: 8px;
}

.wallet-option {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--chat-line);
  border-radius: 12px;
  background: var(--chat-surface-soft);
  color: var(--chat-text);
  cursor: pointer;
  text-align: left;
}

.wallet-option small,
.payment-status,
.funding-help {
  color: var(--chat-muted);
}

.wallet-readiness-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.wallet-readiness-grid > div {
  padding: 10px;
  border: 1px solid var(--chat-line);
  border-radius: 10px;
}

.wallet-readiness-grid span,
.wallet-readiness-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.wallet-readiness-grid span {
  margin-bottom: 4px;
  color: #859188;
  font-size: 10px;
}

.wallet-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0;
}

.payment-status {
  display: block;
  margin-top: 14px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@keyframes chat-message-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chat-dot {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@keyframes chatgpt-review-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 620px) {
  .chat-app-header {
    height: 54px;
    padding-inline: 12px;
  }

  .chat-app {
    height: calc(100dvh - 54px);
    margin-top: 54px;
  }

  .chatgpt-handoff-review .chat-app,
  .chatgpt-handoff-review .conversation-panel {
    min-height: calc(100dvh - 54px);
  }

  .chat-app-brand strong {
    display: none;
  }

  .conversation-log {
    gap: 15px;
    padding: 20px 12px 18px;
  }

  .conversation-message {
    max-width: 88%;
  }

  .conversation-bubble {
    font-size: 14px;
  }

  .chat-composer-form {
    padding-inline: 9px;
  }

  .chat-composer-input-wrap {
    grid-template-columns: minmax(0, 1fr) 36px 40px;
    border-radius: 22px;
  }

  .chat-app-page #bounty-composer-input {
    min-height: 40px;
    padding-inline: 9px;
    font-size: 16px;
  }

  .chat-composer-input-wrap .composer-mic {
    width: 36px;
    height: 36px;
  }

  .chat-send {
    width: 40px;
    height: 40px;
  }

  .conversation-draft .bounty-card-visual {
    height: 150px;
  }

  .conversation-draft .bounty-card-body {
    padding: 16px;
  }

  .conversation-draft .bounty-card-stats {
    grid-template-columns: 1fr;
  }

  .conversation-draft .bounty-stat {
    display: grid;
    grid-template-columns: 78px 1fr;
    align-items: center;
  }

  .conversation-draft .bounty-stat span {
    margin: 0;
  }

  .chat-draft-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chat-draft-actions [data-open-funding] {
    grid-column: 1 / -1;
    margin-left: 0;
  }

  .wallet-readiness-grid {
    grid-template-columns: 1fr;
  }
}

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