:root {
  --chat-ink: #172238;
  --chat-muted: #697386;
  --chat-blue: #1c65d8;
  --chat-blue-dark: #123e8d;
  --chat-border: #dce4ef;
  --chat-surface: #ffffff;
  --chat-background: #f3f6fb;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--chat-ink);
  background: var(--chat-background);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.chat-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.chat-header {
  background: var(--chat-surface);
  border-bottom: 1px solid var(--chat-border);
}

.chat-header .navbar {
  min-height: 76px;
  padding: 0.75rem 0;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--chat-ink);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.navbar-brand img {
  object-fit: contain;
}

.navbar-brand small {
  display: block;
  color: var(--chat-blue);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
}

.back-link,
.frame-toolbar a,
.chat-footer a {
  color: var(--chat-blue-dark);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover,
.frame-toolbar a:hover,
.chat-footer a:hover {
  color: var(--chat-blue);
  text-decoration: underline;
}

.chat-main {
  padding: clamp(2rem, 5vw, 4.5rem) 0 2rem;
}

.chat-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--chat-blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.04;
}

.intro-copy {
  max-width: 600px;
  margin: 1rem 0 0;
  color: var(--chat-muted);
  font-size: 1.05rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: var(--chat-surface);
  color: var(--chat-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #e4a11b;
  box-shadow: 0 0 0 4px #fff3d6;
}

.is-connected .status-dot {
  background: #15945b;
  box-shadow: 0 0 0 4px #dff7eb;
}

.chat-frame-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  background: var(--chat-surface);
  box-shadow: 0 18px 45px rgba(24, 44, 78, 0.1);
}

.frame-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 1rem;
  border-bottom: 1px solid var(--chat-border);
}

.toolbar-title {
  color: var(--chat-muted);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.frame-loading {
  position: absolute;
  z-index: 1;
  top: 52px;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  color: var(--chat-muted);
  background: var(--chat-surface);
  transition: opacity 180ms ease;
}

.frame-loading.is-hidden {
  pointer-events: none;
  opacity: 0;
}

iframe {
  display: block;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 520px;
  border: 0;
}

.chat-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1.25rem;
  padding: 0 0 1.5rem;
  color: var(--chat-muted);
  font-size: 0.82rem;
}

@media (max-width: 640px) {
  .chat-shell {
    width: min(100% - 1.25rem, 1180px);
  }

  .chat-intro {
    align-items: start;
    flex-direction: column;
    gap: 1rem;
  }

  .status-pill {
    align-self: flex-start;
  }

  .frame-toolbar {
    align-items: start;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.65rem 0.8rem;
  }

  .frame-loading {
    top: 68px;
  }

  iframe {
    min-height: 68vh;
    height: 68vh;
  }

  .chat-footer {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .frame-loading {
    transition: none;
  }
}