:root {
  --navy: #0B3C7E;
  --blue: #1B5AA6;
  --navy-dark: #072D59;
  --gold: #D4AF6D;
  --gold-dark: #B8860B;
  --surface: #F7F7F7;
  --white: #ffffff;
  --text: #122033;
  --muted: #5B6B7C;
  --line: #E3E7EE;
  --shadow: 0 10px 30px rgba(7, 45, 89, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
  line-height: 1.5;
}

h1, h2, h3 { font-family: Poppins, Inter, sans-serif; }

.app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  background: var(--white);
  box-shadow: var(--shadow);
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.header img.logo {
  height: 42px;
  width: auto;
  max-width: 132px;
  flex: 0 0 auto;
  background: #fff;
  border-radius: 10px;
  padding: 3px 5px;
}
.header .titles { flex: 1; min-width: 0; }
.header h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.header p {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.8);
  margin-top: 2px;
}
.remaining {
  flex: 0 0 auto;
  font-size: 0.68rem;
  line-height: 1.25;
  text-align: right;
  color: #fff;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(212,175,109,0.55);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
}
.remaining strong { color: var(--gold); font-weight: 600; }

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  background:
    linear-gradient(180deg, rgba(11,60,126,0.04), transparent 120px),
    var(--surface);
}

.bubble-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin: 0 0 14px;
  scroll-margin-top: 96px;
}
.bubble-row.user { justify-content: flex-end; }

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--gold);
}
.avatar img { width: 100%; height: 100%; display: block; }

.bubble {
  max-width: min(80%, 520px);
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.bubble.assistant {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-top-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(7,45,89,0.04);
}
.bubble.user {
  background: linear-gradient(180deg, var(--blue), var(--navy));
  color: #fff;
  border-top-right-radius: 6px;
}
.who {
  display: block;
  font-family: Poppins, Inter, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 4px;
}
.bubble.user .who { color: var(--gold); }

.typing { display: flex; gap: 5px; align-items: center; padding: 6px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--blue);
  animation: bounce 1.1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; background: var(--navy); }
.typing span:nth-child(3) { animation-delay: 0.3s; background: var(--gold); }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 16px 12px;
  background: var(--surface);
}
.chips button {
  font-family: Inter, sans-serif;
  font-size: 0.8rem;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.chips button:hover, .chips button:focus-visible {
  background: var(--navy);
  color: #fff;
  outline: none;
}

.composer {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 10px 16px 8px;
}
.composer form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  font-family: Inter, sans-serif;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
}
.composer textarea:focus {
  outline: 2px solid var(--gold);
  border-color: var(--navy);
  background: #fff;
}
.composer button.send {
  flex: 0 0 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--navy);
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.composer button.send:hover, .composer button.send:focus-visible {
  background: var(--blue);
  outline: none;
}
.composer button.send:disabled { opacity: 0.5; cursor: not-allowed; }

.disclaimer {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 6px 2px 2px;
  line-height: 1.4;
}
.disclaimer a { color: var(--navy); }

.footer {
  text-align: center;
  font-size: 0.68rem;
  color: #8A94A0;
  padding: 6px 16px 12px;
  background: #fff;
}
.footer a { color: #8A94A0; text-decoration: none; }
.footer a:hover { color: var(--navy); text-decoration: underline; }


.bubble.assistant strong { font-weight: 600; color: var(--navy-dark); }

@media (max-width: 699px) {
  .header {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "logo titles"
      "logo remaining";
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
    padding: 10px 12px;
  }
  .header img.logo { grid-area: logo; height: 48px; max-width: 120px; }
  .header .titles { grid-area: titles; min-width: 0; }
  .header h1 { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header p { font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .remaining {
    grid-area: remaining;
    justify-self: start;
    font-size: 0.62rem;
    padding: 4px 8px;
  }
  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 6px 12px 10px;
    scrollbar-width: thin;
  }
  .chips button { flex: 0 0 auto; max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (min-width: 700px) {
  body { background: #e9eef5; padding: 0; }
  .app { min-height: 100dvh; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .header { padding: 14px 22px; }
  .header h1 { font-size: 1.15rem; }
  .chat, .chips, .composer { padding-left: 22px; padding-right: 22px; }
  .header img.logo { height: 52px; max-width: 200px; }
}
