/* Yuzzi chat widget. Rules are scoped to #yz-chat-panel so site styles cannot override them. */
.yz-chat-launcher, #yz-chat-panel, #yz-chat-panel * { box-sizing: border-box; }

/* Launcher */
button.yz-chat-launcher {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: inline-flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 20px 0 16px; margin: 0;
  border: 0; border-radius: 999px;
  background: var(--navy-800, #0C447C); color: #fff;
  font: 600 15px/1 var(--display, system-ui, sans-serif);
  box-shadow: 0 8px 24px rgba(10, 22, 40, .28), 0 1px 2px rgba(10, 22, 40, .2);
  cursor: pointer;
  transition: background .15s ease;
}
button.yz-chat-launcher:hover { background: var(--navy-600, #185FA5); }
button.yz-chat-launcher[hidden] { display: none; }

/* Panel */
#yz-chat-panel {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  z-index: 1001;
  width: 408px; max-width: calc(100vw - 32px);
  height: min(660px, calc(100vh - 40px));
  height: min(660px, calc(100dvh - 40px));
  display: flex; flex-direction: column;
  margin: 0; padding: 0;
  background: #fff; color: var(--ink, #0A1628);
  border: 1px solid rgba(10, 22, 40, .12); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(10, 22, 40, .28), 0 2px 6px rgba(10, 22, 40, .12);
  overflow: hidden;
  font: 15px/1.55 var(--body, system-ui, sans-serif);
  transform-origin: bottom right;
  animation: yz-pop .18s ease-out;
}
#yz-chat-panel[hidden] { display: none; }
@keyframes yz-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* Header */
#yz-chat-panel .yz-chat-header {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 12px 8px 12px 16px;
  background: var(--ink, #0A1628); color: #fff;
}
#yz-chat-panel .yz-chat-mark {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--navy-600, #185FA5);
}
#yz-chat-panel .yz-chat-title { flex: 1; min-width: 0; }
#yz-chat-panel .yz-chat-title strong { display: block; font: 600 16px/1.2 var(--display, system-ui, sans-serif); }
#yz-chat-panel .yz-chat-title span { display: block; margin-top: 2px; font-size: 12.5px; color: rgba(255, 255, 255, .7); }
#yz-chat-panel button.yz-chat-ctl {
  flex: 0 0 auto; width: 40px; height: 40px; padding: 0; margin: 0;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px; color: #fff; cursor: pointer;
}
#yz-chat-panel button.yz-chat-ctl:hover { background: rgba(255, 255, 255, .12); }

/* Conversation */
#yz-chat-panel .yz-chat-log {
  flex: 1 1 auto; position: relative; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  background: var(--paper, #F7F8FA);
}
#yz-chat-panel .yz-msg { max-width: 88%; padding: 10px 14px; border-radius: 14px; overflow-wrap: anywhere; }
#yz-chat-panel .yz-msg p { margin: 0 0 8px; }
#yz-chat-panel .yz-msg p:last-child, #yz-chat-panel .yz-msg ul:last-child, #yz-chat-panel .yz-msg ol:last-child { margin-bottom: 0; }
#yz-chat-panel .yz-msg ul, #yz-chat-panel .yz-msg ol { margin: 0 0 8px; padding-left: 20px; }
#yz-chat-panel .yz-msg ul { list-style: disc; }
#yz-chat-panel .yz-msg ol { list-style: decimal; }
#yz-chat-panel .yz-msg li { margin: 3px 0; }
#yz-chat-panel .yz-bot { align-self: flex-start; background: #fff; border: 1px solid var(--ash-100, #E7E9EC); border-bottom-left-radius: 4px; }
#yz-chat-panel .yz-user { align-self: flex-end; background: var(--navy-800, #0C447C); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
#yz-chat-panel .yz-msg a { color: var(--navy-600, #185FA5); text-decoration: underline; text-underline-offset: 2px; }
#yz-chat-panel .yz-msg a.yz-source {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; padding: 8px 12px;
  border: 1px solid var(--ash-100, #E7E9EC); border-radius: 10px; background: var(--paper, #F7F8FA);
  color: var(--navy-800, #0C447C); font-weight: 500; font-size: 14px; text-decoration: none;
}
#yz-chat-panel .yz-msg a.yz-source:hover { border-color: var(--navy-600, #185FA5); background: #fff; }

/* Typing indicator */
#yz-chat-panel .yz-typing { display: inline-flex; align-items: center; gap: 5px; padding: 15px 16px; }
#yz-chat-panel .yz-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ash-300, #C7CBD1); animation: yz-dot 1.2s infinite ease-in-out; }
#yz-chat-panel .yz-typing span:nth-child(2) { animation-delay: .15s; }
#yz-chat-panel .yz-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes yz-dot { 0%, 80%, 100% { opacity: .35; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* Starter questions */
#yz-chat-panel .yz-starters { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
#yz-chat-panel button.yz-starter {
  margin: 0; padding: 9px 14px; text-align: left;
  background: #fff; color: var(--navy-800, #0C447C);
  border: 1px solid rgba(24, 95, 165, .35); border-radius: 999px;
  font: 500 14px/1.35 var(--body, system-ui, sans-serif); cursor: pointer;
}
#yz-chat-panel button.yz-starter:hover { background: var(--navy-800, #0C447C); border-color: var(--navy-800, #0C447C); color: #fff; }

/* Composer */
#yz-chat-panel form.yz-chat-form {
  flex: 0 0 auto; display: flex; flex-direction: row; align-items: center; gap: 8px;
  margin: 0; padding: 12px; background: #fff; border-top: 1px solid var(--ash-100, #E7E9EC);
}
#yz-chat-panel input.yz-chat-input {
  flex: 1 1 auto; width: auto; min-width: 0; max-width: none; height: 46px; margin: 0; padding: 0 14px;
  font: 16px/1.2 var(--body, system-ui, sans-serif); /* 16px stops iPhone zooming the page on focus */
  color: var(--ink, #0A1628); background: var(--paper, #F7F8FA);
  border: 1px solid var(--ash-300, #C7CBD1); border-radius: 12px; box-shadow: none;
}
#yz-chat-panel input.yz-chat-input:focus { background: #fff; border-color: var(--navy-600, #185FA5); }
#yz-chat-panel button.yz-chat-send {
  flex: 0 0 46px; width: 46px; height: 46px; margin: 0; padding: 0;
  display: grid; place-items: center;
  background: var(--navy-800, #0C447C); color: #fff; border: 0; border-radius: 12px; cursor: pointer;
}
#yz-chat-panel button.yz-chat-send:hover { background: var(--navy-600, #185FA5); }
#yz-chat-panel button.yz-chat-send:disabled { opacity: .45; cursor: default; }

/* Footer: speak to a person */
#yz-chat-panel .yz-chat-foot {
  flex: 0 0 auto; margin: 0; background: #fff; border-top: 1px solid var(--ash-100, #E7E9EC);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}
#yz-chat-panel .yz-foot-title { margin: 0 0 8px; font: 600 13px/1.3 var(--display, system-ui, sans-serif); color: var(--ink, #0A1628); }
#yz-chat-panel .yz-foot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#yz-chat-panel a.yz-contact {
  min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 9px 10px;
  background: var(--paper, #F7F8FA); border: 1px solid var(--ash-100, #E7E9EC); border-radius: 10px;
  color: var(--ink, #0A1628); text-decoration: none;
}
#yz-chat-panel a.yz-contact:hover { background: #fff; border-color: var(--navy-600, #185FA5); }
#yz-chat-panel .yz-contact-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--ash-600, #5F5E5A); }
#yz-chat-panel .yz-contact-label svg { color: var(--navy-600, #185FA5); }
#yz-chat-panel .yz-contact-value { font-size: 12px; font-weight: 600; color: var(--navy-800, #0C447C); white-space: nowrap; }
#yz-chat-panel .yz-foot-note { margin: 8px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--ash-600, #5F5E5A); }

/* Keyboard focus */
button.yz-chat-launcher:focus-visible, #yz-chat-panel button:focus-visible, #yz-chat-panel a:focus-visible, #yz-chat-panel input:focus-visible {
  outline: 3px solid var(--amber-400, #EF9F27); outline-offset: 2px;
}

/* Maximized, minimized */
#yz-chat-panel.yz-maximized { width: min(820px, calc(100vw - 40px)); height: min(900px, calc(100vh - 40px)); height: min(900px, calc(100dvh - 40px)); }
#yz-chat-panel.yz-maximized .yz-chat-log { padding: 24px 32px; }
#yz-chat-panel.yz-maximized .yz-msg { max-width: 78%; font-size: 16px; }
#yz-chat-panel.yz-minimized { height: auto; }
#yz-chat-panel.yz-minimized .yz-chat-log, #yz-chat-panel.yz-minimized form.yz-chat-form, #yz-chat-panel.yz-minimized .yz-chat-foot { display: none; }
#yz-chat-panel.yz-minimized .yz-chat-header { cursor: pointer; }

/* Narrow screens: contact tiles stack as aligned rows */
@media (max-width: 440px) {
  #yz-chat-panel .yz-foot-grid { grid-template-columns: 1fr; }
  #yz-chat-panel a.yz-contact { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 12px; }
  #yz-chat-panel .yz-contact-value { font-size: 13px; }
}

/* Phones: bottom sheet; maximize fills the screen */
@media (max-width: 520px) {
  button.yz-chat-launcher { width: 56px; height: 56px; padding: 0; justify-content: center; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); }
  button.yz-chat-launcher .yz-launch-label { display: none; }
  #yz-chat-panel { left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; border-bottom: 0; height: min(88vh, 720px); height: min(88dvh, 720px); }
  #yz-chat-panel.yz-maximized { top: 0; width: 100%; height: 100vh; height: 100dvh; border-radius: 0; }
  #yz-chat-panel.yz-maximized .yz-chat-log { padding: 16px; }
  #yz-chat-panel.yz-maximized .yz-msg { max-width: 88%; }
  #yz-chat-panel.yz-minimized { height: auto; }
}

@media (prefers-reduced-motion: reduce) {
  #yz-chat-panel { animation: none; }
  #yz-chat-panel .yz-typing span { animation: none; opacity: .6; }
  button.yz-chat-launcher { transition: none; }
}
