:root {
  --navy: #06134f;
  --blue: #087bd5;
  --blue-dark: #0568bd;
  --sky: #28c3f2;
  --ink: #10194d;
  --muted: #59617e;
  --line: #dce8f3;
  --paper: #ffffff;
  --soft-blue: #eef9ff;
  --pink: #f43f7a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-width: 320px;
  color: var(--ink);
  background: #f8fcff;
}

button,
input,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.primary-nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: #fff;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 900;
}

.primary-nav a:hover,
.primary-nav a:focus-visible { color: #075eb5; background: #fff; }

.site-menu { display: none; position: relative; }

.site-menu summary {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: #fff;
  border: 2px solid rgba(255,255,255,.62);
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.site-menu summary::-webkit-details-marker { display: none; }
.site-menu summary::after { content: "▾"; margin-left: 7px; font-size: .78em; }
.site-menu[open] summary { color: #075eb5; background: #fff; }

.site-menu nav {
  position: absolute;
  z-index: 100;
  top: calc(100% + 9px);
  right: 0;
  width: 220px;
  padding: 8px;
  background: #fff;
  border: 1px solid #bcdff1;
  border-radius: 15px;
  box-shadow: 0 16px 38px rgba(5,62,119,.25);
}

.site-menu nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 9px 11px;
  color: #075eb5;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 900;
}

.site-menu nav a:hover,
.site-menu nav a:focus-visible { background: #e6f7ff; }

.brand span {
  text-transform: none;
  letter-spacing: -.025em;
}

.audience-note {
  width: fit-content;
  max-width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: -7px auto 13px;
  padding: 5px 8px 5px 5px;
  color: #12346a;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(8,123,213,.24);
  border-radius: 999px;
  box-shadow: 0 5px 16px rgba(7,93,154,.12);
  font-size: .86rem;
  font-weight: 800;
}

.audience-note strong {
  display: inline-grid;
  place-items: center;
  min-width: 43px;
  min-height: 30px;
  color: #fff;
  background: #087bd5;
  border-radius: 999px;
  font: 700 .9rem/1 "Fredoka", sans-serif;
}

.audience-note button {
  min-height: 30px;
  padding: 4px 9px;
  color: #075eb5;
  background: #e6f7ff;
  border: 0;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 900;
  cursor: pointer;
}

.audience-note button:hover,
.audience-note button:focus-visible { color: #fff; background: #087bd5; }

.age-dialog .dialog-primary { min-height: 50px; }
.age-cancel { display: block; margin-top: 14px; color: #53617d; text-align: center; font-weight: 900; }

.home-button {
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  border: 2px solid rgba(255,255,255,.6);
  border-radius: 16px;
  padding: 10px 15px;
}

.home-button:hover,
.home-button:focus-visible { background: rgba(255,255,255,.14); }

.site-footer {
  background: #fff;
  border-top: 1px solid #dceaf4;
  padding: 22px clamp(18px, 4vw, 60px);
}

.footer-inner {
  width: min(1480px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #4b5675;
  font-size: .95rem;
}

.footer-inner p { margin: 0; font-weight: 800; }

.footer-inner nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 20px;
}

.footer-inner a {
  color: #075eb5;
  font-weight: 800;
  text-underline-offset: 3px;
}

.chat-page {
  position: relative;
  min-height: calc(100svh - 86px);
  padding: 12px clamp(12px, 3vw, 42px) 18px;
  background:
    linear-gradient(180deg, #2bc4f3 0, #c8f3ff 155px, #f7fcff 390px),
    #f7fcff;
  overflow: hidden;
}

.chat-sky {
  position: absolute;
  inset: 0 0 auto;
  height: 155px;
  pointer-events: none;
  color: #fff;
}

.chat-sky span { position: absolute; filter: drop-shadow(0 2px 2px rgba(7,83,149,.22)); }
.chat-sky span:nth-child(1) { left: 7%; top: 20px; font-size: 20px; }
.chat-sky span:nth-child(2) { left: 27%; top: 62px; font-size: 15px; }
.chat-sky span:nth-child(3) { right: 13%; top: 25px; font-size: 21px; }
.chat-sky span:nth-child(4) { right: 33%; top: 70px; font-size: 16px; }

.chat-page-inner {
  position: relative;
  z-index: 1;
  width: min(1390px, 100%);
  margin: 0 auto;
}

.chat-heading {
  display: grid;
  grid-template-columns: minmax(230px, 310px) minmax(0, 1fr);
  gap: 16px;
  margin: 0 auto 9px;
}

.chat-heading h1 {
  grid-column: 2;
  text-align: left;
  margin: 0;
  color: var(--navy);
  font: 700 clamp(1.8rem, 3.2vw, 2.55rem)/1.05 "Fredoka", sans-serif;
  text-shadow: 0 2px 0 rgba(255,255,255,.65);
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(230px, 310px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  height: calc(100svh - 174px);
  min-height: 520px;
  max-height: 740px;
}

.guide-profile,
.conversation {
  background: rgba(255,255,255,.97);
  border: 4px solid #fff;
  box-shadow: 0 14px 38px rgba(6,84,142,.16), 0 0 0 1px rgba(7,111,179,.12);
  border-radius: 28px;
}

.guide-profile {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
}

.profile-visual {
  min-height: 195px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #dff5ff;
}

.profile-visual img {
  width: 100%;
  height: 205px;
  object-fit: contain;
  padding: 12px;
}

.profile-role {
  align-self: center;
  position: relative;
  z-index: 2;
  margin-top: -20px;
  border: 3px solid #fff;
}

.guide-profile h2 {
  margin: 8px 0 2px;
  color: var(--navy);
  font: 700 2rem/1 "Fredoka", sans-serif;
}

.guide-profile > p {
  margin: 5px auto 10px;
  max-width: 29ch;
  color: #3b476d;
  font-weight: 700;
  line-height: 1.45;
}

.prompt-box {
  text-align: left;
  background: #f3faff;
  border: 1px solid #d9ecf8;
  border-radius: 18px;
  padding: 11px;
  margin-top: auto;
}

.prompt-box h3 {
  margin: 0 0 9px;
  color: var(--navy);
  font: 700 1.05rem/1.2 "Fredoka", sans-serif;
}

#prompt-suggestions { display: grid; gap: 7px; }

.prompt-suggestion {
  width: 100%;
  border: 1px solid #b9dff4;
  border-radius: 12px;
  padding: 7px 9px;
  text-align: left;
  color: #075eb5;
  background: #fff;
  font-size: .9rem;
  line-height: 1.28;
  font-weight: 800;
  cursor: pointer;
}

.prompt-suggestion:hover,
.prompt-suggestion:focus-visible { background: #e7f6ff; border-color: #158bd1; }

.report-link {
  display: inline-block;
  align-self: center;
  margin-top: 14px;
  color: #53617d;
  font-size: .86rem;
  font-weight: 800;
}

.conversation {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-safety {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 15px;
  color: #16426a;
  background: #e9f8ff;
  border-bottom: 1px solid #cceafa;
  line-height: 1.35;
  font-size: .9rem;
}

.chat-safety strong { display: block; color: #06396b; margin-bottom: 2px; }

.safety-shield {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 34px;
  color: #fff;
  background: #0aa7d5;
  border-radius: 14px 14px 17px 17px;
  font-weight: 900;
  clip-path: polygon(50% 0, 94% 16%, 88% 74%, 50% 100%, 12% 74%, 6% 16%);
}

.conversation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 8px 15px;
  border-bottom: 1px solid #edf1f5;
}

.conversation-toolbar > span { font-weight: 900; color: var(--navy); }
.conversation-toolbar > div { display: flex; gap: 8px; }

.conversation-toolbar button {
  border: 1px solid #c7dcea;
  border-radius: 10px;
  padding: 7px 10px;
  color: #315077;
  background: #fff;
  font-size: .82rem;
  font-weight: 900;
  cursor: pointer;
}

.conversation-toolbar button:hover,
.conversation-toolbar button:focus-visible { border-color: #0a82cf; color: #075eb5; }

.message-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  background:
    radial-gradient(circle at 1px 1px, rgba(26,160,213,.10) 1.2px, transparent 1.3px) 0 0/22px 22px,
    #fbfdff;
}

.chat-message {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 0 17px;
}

.chat-message--user { justify-content: flex-end; }

.message-avatar {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 2px solid #d5e9f7;
  border-radius: 16px;
  overflow: hidden;
  background: #e8f7ff;
}

.message-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }

.message-bubble { max-width: min(76%, 720px); }

.message-name {
  display: block;
  margin: 0 8px 4px;
  color: #52617c;
  font-size: .76rem;
  font-weight: 900;
}

.chat-message--user .message-name { text-align: right; }

.message-text {
  margin: 0;
  padding: 12px 15px;
  border-radius: 8px 19px 19px 19px;
  color: #1f2c50;
  background: #fff;
  border: 1px solid #dce9f2;
  box-shadow: 0 5px 14px rgba(37,89,128,.08);
  font-weight: 650;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.message-text p { margin: 0 0 .65em; }
.message-text p:last-child { margin-bottom: 0; }
.message-text ul,
.message-text ol { margin: .5em 0 .5em 1.25em; padding: 0; }
.message-text li { margin: .25em 0; }
.message-text strong { color: inherit; font-weight: 900; }

.chat-message--user .message-text {
  color: #fff;
  background: linear-gradient(135deg, #118ce1, #0875cb);
  border: 0;
  border-radius: 19px 8px 19px 19px;
}

.message-time {
  display: block;
  margin: 4px 8px 0;
  color: #77829a;
  font-size: .7rem;
  font-weight: 700;
}

.chat-message--user .message-time { text-align: right; }

.typing-status {
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  color: #52617c;
  background: #fbfdff;
  font-size: .83rem;
  font-weight: 800;
}

.typing-status:not([hidden]) { display: flex; }

.typing-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: #178bd0; animation: typing 1s infinite alternate; }
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes typing { to { opacity: .25; transform: translateY(-2px); } }

.chat-composer {
  padding: 9px 14px 10px;
  border-top: 1px solid #e5edf3;
  background: #fff;
}

.chat-composer > label {
  display: block;
  margin-bottom: 6px;
  color: var(--navy);
  font-size: .85rem;
  font-weight: 900;
}

.composer-row { display: flex; align-items: stretch; gap: 10px; }

.composer-row textarea {
  flex: 1;
  min-height: 52px;
  max-height: 150px;
  resize: vertical;
  border: 2px solid #cbddea;
  border-radius: 14px;
  padding: 11px 13px;
  color: #17234e;
  background: #fbfdff;
  line-height: 1.4;
  outline: none;
}

.composer-row textarea:focus { border-color: #138fd7; box-shadow: 0 0 0 4px rgba(19,143,215,.13); }

.send-button {
  min-width: 116px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 14px;
  padding: 0 19px;
  color: #fff;
  background: linear-gradient(135deg, #118ce1, #066ccc);
  box-shadow: 0 6px 0 #055da8;
  font-weight: 900;
  cursor: pointer;
}

.send-button:hover:not(:disabled),
.send-button:focus-visible:not(:disabled) { transform: translateY(-1px); filter: brightness(1.05); }
.send-button:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 #055da8; }
.send-button:disabled { opacity: .55; cursor: not-allowed; }

.composer-help {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 7px;
  color: #6d7890;
  font-size: .74rem;
  line-height: 1.3;
}

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(92vw, 580px);
  padding: 12px 16px;
  color: #fff;
  background: #14204f;
  border-radius: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.23);
  font-weight: 800;
}

.toast.is-error { background: #9f2449; }

:focus-visible { outline: 3px solid #ffb000; outline-offset: 3px; }

@media (max-width: 900px) and (min-width: 721px) {
  .chat-page { padding-inline: 12px; }
  .chat-layout {
    grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
    gap: 12px;
    height: calc(100svh - 160px);
    min-height: 500px;
  }
  .chat-heading { grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); gap: 12px; }
  .guide-profile { padding: 11px; border-radius: 22px; }
  .profile-visual { min-height: 145px; }
  .profile-visual img { height: 158px; padding: 8px; }
  .guide-profile h2 { font-size: 1.55rem; }
  .guide-profile > p { font-size: .88rem; line-height: 1.3; }
  .prompt-box { padding: 9px; }
  .prompt-box h3 { margin-bottom: 6px; font-size: .95rem; }
  #prompt-suggestions { gap: 5px; }
  .prompt-suggestion { padding: 6px 7px; font-size: .78rem; }
  .prompt-suggestion:nth-child(n+4) { display: none; }
  .report-link { margin-top: 8px; font-size: .75rem; }
}

@media (max-width: 720px) {
  .chat-page {
    min-height: calc(100svh - 78px);
    padding: 8px 8px 10px;
    background: linear-gradient(180deg, #2bc4f3 0, #c8f3ff 110px, #f7fcff 280px);
  }
  .chat-sky { height: 110px; }
  .chat-heading { margin-bottom: 7px; }
  .chat-heading { display: block; }
  .chat-heading h1 { font-size: clamp(1.6rem, 7vw, 2rem); text-align: left; }
  .chat-layout {
    display: block;
    height: calc(100svh - 133px);
    min-height: 420px;
    max-height: none;
  }
  .guide-profile { display: none; }
  .conversation { height: 100%; border-radius: 20px; border-width: 3px; }
}

@media (max-width: 900px) {
  .primary-nav { display: none; }
  .site-menu { display: block; }
}

@media (max-width: 650px) {
  .brand span { font-size: clamp(1.25rem, 6vw, 1.75rem); }
  .brand-mark { width: 43px; }
  .grownups-button span { display: none; }
  .grownups-button { padding: 9px 11px; }
  .home-button { font-size: .8rem; padding: 8px 9px; }
  .audience-note { flex-wrap: wrap; width: min(100%, 330px); gap: 5px 8px; border-radius: 18px; }
  .audience-note button { flex-basis: 100%; }
  .chat-safety { gap: 8px; padding: 8px 10px; font-size: .76rem; line-height: 1.25; }
  .safety-shield { width: 25px; height: 28px; }
  .conversation-toolbar { padding: 6px 9px; }
  .conversation-toolbar > span { display: none; }
  .conversation-toolbar > div { width: 100%; justify-content: flex-end; }
  .conversation-toolbar button { padding: 6px 8px; font-size: .75rem; }
  .message-list { padding: 10px 8px; min-height: 0; }
  .chat-message { gap: 7px; margin-bottom: 11px; }
  .message-avatar { width: 35px; height: 35px; border-radius: 12px; }
  .message-bubble { max-width: 87%; }
  .message-name { margin-bottom: 2px; }
  .message-text { font-size: .88rem; padding: 9px 11px; line-height: 1.4; }
  .message-text p { margin-bottom: .5em; }
  .typing-status { padding: 5px 10px; }
  .chat-composer { padding: 7px 9px 8px; }
  .chat-composer > label { margin-bottom: 4px; font-size: .78rem; }
  .composer-row { gap: 7px; }
  .composer-row textarea { min-height: 46px; padding: 9px 10px; }
  .send-button { min-width: 88px; min-height: 46px; padding-inline: 12px; box-shadow: 0 4px 0 #055da8; }
  .composer-help span:first-child { display: none; }
  .composer-help { justify-content: flex-end; margin-top: 4px; }
  .footer-inner { flex-direction: column; text-align: center; }
  .footer-inner nav { justify-content: center; }
}

@media (max-width: 390px) {
  .brand span { font-size: 1.16rem; }
  .brand-mark { width: 38px; }
  .header-actions { gap: 6px; }
  .home-button { font-size: 0; padding: 8px 10px; }
  .home-button::after { content: "←"; font-size: 1rem; }
  .chat-safety { font-size: .71rem; }
  .send-button { min-width: 64px; }
  .send-button span:first-child { display: none; }
}

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