:root {
  --brand-blue: #1f3cff;
  --brand-blue-deep: #1427b7;
  --brand-coral: #ff6b5f;
  --brand-coral-soft: #ffe3de;
  --bg: #f5f7ff;
  --panel: rgba(255, 251, 247, 0.94);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --ink: #10203f;
  --muted: #617091;
  --line: rgba(31, 60, 255, 0.12);
  --shadow: 0 28px 80px rgba(16, 32, 63, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(31, 60, 255, 0.22), transparent 24%),
    radial-gradient(circle at bottom right, rgba(255, 107, 95, 0.12), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Aptos, "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  min-height: 100dvh;
}

.landing {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.landing-card,
.chat-frame {
  width: min(960px, 100%);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.landing-card {
  padding: 44px;
  position: relative;
  overflow: hidden;
}

.landing-card::after {
  content: "";
  position: absolute;
  inset: auto -60px -80px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 107, 95, 0.2), transparent 68%);
  pointer-events: none;
}

.eyebrow,
.message-role {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--brand-blue);
  font-weight: 700;
}

h1 {
  margin: 10px 0 14px;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  line-height: 0.98;
  color: var(--ink);
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.primary-link,
.secondary-link,
.composer-button {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.primary-link,
.composer-button {
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-deep) 100%);
  color: #f8fbff;
  box-shadow: 0 14px 32px rgba(31, 60, 255, 0.28);
}

.primary-link:hover,
.composer-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.secondary-link {
  background: var(--brand-coral-soft);
  color: #a53a32;
}

.chat-frame {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  max-width: 1120px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-frame.embed {
  width: 100%;
  max-width: none;
  border-radius: 0;
  box-shadow: none;
  border: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 255, 0.98) 100%);
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 28px 28px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(31, 60, 255, 0.08) 0%, rgba(255, 255, 255, 0.9) 48%, rgba(255, 107, 95, 0.08) 100%);
}

.chat-header h1 {
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  margin: 6px 0 0;
}

.badge-chip {
  background: var(--brand-coral-soft);
  color: #a53a32;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 700;
}

.chat-state {
  padding: 28px;
  color: var(--muted);
}

.chat-state.error {
  color: #a53a32;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: min(760px, 100%);
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid rgba(31, 60, 255, 0.1);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 28px rgba(16, 32, 63, 0.06);
}

.message.pending {
  opacity: 0.85;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-deep) 100%);
  border-color: rgba(31, 60, 255, 0.24);
  color: #f8fbff;
}

.message.user .message-role {
  color: rgba(248, 251, 255, 0.76);
}

/* A message from a human support rep during a live handoff. */
.message.rep {
  align-self: flex-start;
  border-color: rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.08);
}

.message.rep .message-role {
  color: #15803d;
}

.support-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  background: rgba(22, 163, 74, 0.1);
  border-top: 1px solid rgba(22, 163, 74, 0.25);
  font-size: 0.9rem;
  color: #15803d;
}

.support-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a34a;
  flex: 0 0 auto;
  animation: support-pulse 1.8s infinite;
}

@keyframes support-pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

.support-end {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(22, 163, 74, 0.5);
  color: #15803d;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
}

.support-end:hover {
  background: rgba(22, 163, 74, 0.12);
}

.message-body {
  margin-top: 6px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.composer-shell {
  flex: 0 0 auto;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 20px 28px 28px;
  border-top: 1px solid var(--line);
  background: var(--panel-strong);
}

.composer-input {
  width: 100%;
  min-height: 88px;
  max-height: 180px;
  resize: vertical;
  border-radius: 20px;
  border: 1px solid rgba(31, 60, 255, 0.14);
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.composer-input:focus {
  outline: 2px solid rgba(31, 60, 255, 0.18);
  border-color: rgba(31, 60, 255, 0.34);
}

.composer-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
}

@media (max-width: 720px) {
  .landing,
  .chat-header,
  .messages,
  .composer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .landing-card {
    padding: 28px;
  }

  .composer {
    grid-template-columns: 1fr;
  }
}

/* ---- Embedded admin assistant (DisplayMode "app"): tighter, flatter, on-brand ---- */
.chat-frame.app {
  --radius: 6px;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  background: #fff;
}

.chat-frame.app .chat-header {
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid #e6e8f0;
}

.chat-frame.app .eyebrow {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
}

.chat-frame.app .chat-header h1 {
  font-size: 1.1rem;
  margin: 2px 0 0;
  color: #00023c;
}

.chat-frame.app .badge-chip {
  display: none;
}

.chat-frame.app .messages {
  padding: 14px 16px;
  gap: 10px;
}

.chat-frame.app .message {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid #e6e8f0;
  background: #f4f6fb;
  box-shadow: none;
  font-size: 0.875rem;
}

.chat-frame.app .message.user {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
}

.chat-frame.app .message.user .message-role {
  color: rgba(255, 255, 255, 0.8);
}

.chat-frame.app .message-role {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
}

.chat-frame.app .message-body {
  margin-top: 4px;
  line-height: 1.5;
}

.chat-frame.app .composer {
  padding: 12px 16px 16px;
  background: #fff;
  border-top: 1px solid #e6e8f0;
}

.chat-frame.app .composer-input {
  min-height: 60px;
  border-radius: var(--radius);
  border-color: #d6d9e6;
  font-size: 0.875rem;
  box-shadow: none;
}

.chat-frame.app .composer-button {
  border-radius: var(--radius);
  background: var(--brand-blue);
  box-shadow: none;
  padding: 10px 18px;
}

/* Proposed-change approval card */
.action-card {
  margin-top: 10px;
  border: 1px solid #d6d9e6;
  border-radius: var(--radius, 6px);
  background: #fff;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.action-summary {
  font-weight: 700;
  color: #00023c;
  margin-bottom: 6px;
}

.action-preview {
  max-height: 160px;
  overflow: auto;
  white-space: pre-wrap;
  background: #f4f6fb;
  border: 1px solid #e6e8f0;
  border-radius: var(--radius, 6px);
  padding: 8px 10px;
  color: #2a3450;
}

.action-buttons {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.action-apply,
.action-dismiss {
  border: 0;
  border-radius: var(--radius, 6px);
  padding: 7px 14px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
}

.action-apply {
  background: var(--brand-blue);
  color: #fff;
}

.action-dismiss {
  background: rgba(0, 2, 60, 0.06);
  color: #00023c;
}

.action-applied {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  color: #1f7a3d;
}

.action-applied.unconfirmed {
  color: #8a6d1f;
}

.action-applying {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--brand-blue, #2563eb);
}

.action-failed {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  color: #b3261e;
}

.playground-tools {
  align-items: start;
  padding-top: 40px;
  overflow: auto;
}

.tools-card {
  max-width: 980px;
  width: min(980px, 100%);
}

.status-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  margin: 24px 0 18px;
}

.status-panel.ok {
  box-shadow: 0 10px 24px rgba(31, 60, 255, 0.08);
}

.status-panel.error {
  border-color: rgba(255, 107, 95, 0.35);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-group label {
  font-weight: 700;
  color: var(--ink);
}

.tools-span-all {
  grid-column: 1 / -1;
}

.tools-input {
  min-height: 56px;
}

.tools-message,
.tools-error {
  margin-top: 16px;
}

.tools-error {
  color: #a53a32;
}

.tools-result {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(16, 32, 63, 0.92);
  color: #eef3ff;
  overflow: auto;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .tools-grid {
    grid-template-columns: 1fr;
  }

  .tools-span-all {
    grid-column: auto;
  }

  .status-panel {
    flex-direction: column;
    align-items: start;
  }
}

