.portfolio-chat-launcher {
  position: fixed;
  z-index: 60;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 18px;
  border: 1px solid #b8d2ff6e;
  border-radius: 99px;
  background: linear-gradient(115deg, #a6e7ff, #c3b2ff);
  box-shadow: 0 5px 30px #03081599, 0 0 24px #9495e51a;
  color: #111a30;
  font: 500 12px var(--sans);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.portfolio-chat-launcher:hover { transform: translateY(-3px); box-shadow: 0 8px 35px #030815aa, 0 0 25px #9495e540; }
.portfolio-chat-launcher svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.portfolio-chat-launcher:focus-visible, .portfolio-chat button:focus-visible, .portfolio-chat a:focus-visible { outline: 2px solid #91e5ff; outline-offset: 4px; }
body.portfolio-chat-open { overflow: hidden; }
.portfolio-chat {
  box-sizing: border-box;
  position: fixed;
  inset: auto max(22px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) auto;
  margin: 0;
  width: min(430px, calc(100vw - 32px));
  height: min(660px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid #788db45e;
  border-radius: 24px;
  overflow: hidden;
  color: #f1f4ff;
  background: radial-gradient(ellipse at 0 0, #58458138, transparent 60%), #101523;
  box-shadow: 0 25px 90px #000a;
  font-family: var(--sans);
  overscroll-behavior: contain;
}
.portfolio-chat::backdrop { background: #0508139c; backdrop-filter: blur(5px); }
.portfolio-chat[open] { display: flex; flex-direction: column; animation: chat-enter .2s ease-out; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 21px 20px 17px; border-bottom: 1px solid #667d9f2d; flex: none; }
.chat-orb { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 14px; color: #e9ddff; font-size: 25px; background: linear-gradient(135deg, #294362, #514172); border: 1px solid #9fb4e243; }
.chat-heading { min-width: 0; flex: 1; }
.chat-heading h2 { margin: 0; color: #e6eaff; font: 500 16px/1.35 var(--sans); letter-spacing: -.4px; }
.chat-heading p { margin: 4px 0 0; color: #a8b7d0; font: 400 10px/1.5 var(--sans); }
.chat-close { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 1px solid #667a9a42; border-radius: 50%; background: #26324c70; color: #c6d4ed; font: 400 22px/1 var(--sans); cursor: pointer; }
.chat-close:hover { background: #344563; }
.chat-scope { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; color: #9fb1cc; font: 400 10px/1.4 var(--sans); flex: none; }
.chat-scope span { display: inline-flex; align-items: center; gap: 6px; }
.chat-scope i { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #a5e5ff; }
.chat-clear { border: 0; background: transparent; padding: 5px 0; color: #c8b7f5; text-decoration: underline; text-underline-offset: 3px; font: 400 10px/1.4 var(--sans); white-space: nowrap; cursor: pointer; }
.chat-log { min-height: 0; flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 5px 20px 18px; scrollbar-width: thin; scrollbar-color: #637395 #141b2c; scroll-padding-bottom: 18px; }
.chat-message { max-width: 95%; padding: 14px 15px; margin: 0 0 13px; border-radius: 16px 16px 16px 4px; border: 1px solid #667a9b26; background: #1d263b7a; overflow-wrap: anywhere; }
.chat-message-user { max-width: 88%; margin-left: auto; border-radius: 16px 16px 4px 16px; color: #e1dcf5; background: linear-gradient(130deg, #333355, #302943); border-color: #b3a5e42e; }
.chat-speaker { display: block; margin-bottom: 6px; color: #9bc9e8; font: 500 9px/1.4 var(--sans); letter-spacing: .4px; }
.chat-message-user .chat-speaker { color: #c2b4ec; }
.chat-message p { margin: 0; color: #c0cde5; white-space: pre-line; font: 400 13px/1.75 var(--sans); }
.chat-message-user p { color: #e1dcf5; }
.chat-message-links { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 12px; }
.chat-message-links a { color: #a7ddff; font: 500 11px/1.5 var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.chat-message-links a:hover { color: #d1bfff; }
.chat-starters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 20px 18px; flex: none; }
.chat-starters[hidden] { display: none; }
.chat-starters button { min-height: 42px; padding: 10px 11px; text-align: left; border: 1px solid #7187b143; border-radius: 12px; color: #c2cee9; background: #1c284170; font: 400 10px/1.5 var(--sans); cursor: pointer; transition: background .2s ease, border-color .2s ease; }
.chat-starters button:hover { background: #344262; border-color: #a4bae979; }
.chat-compose { flex: none; padding: 16px 20px max(14px, env(safe-area-inset-bottom)); border-top: 1px solid #667d9f2d; background: #111827b3; }
.chat-form { display: flex; align-items: center; gap: 8px; padding: 6px 7px 6px 12px; border: 1px solid #7892b85e; border-radius: 14px; background: #192337; }
.chat-form:focus-within { border-color: #a1d7ee; box-shadow: 0 0 0 2px #90dfff14; }
.chat-form input { min-width: 0; flex: 1; width: 100%; padding: 6px 0; border: 0; outline: none; background: transparent; color: #e0e9ff; font: 400 16px/1.5 var(--sans); }
.chat-form input::placeholder { color: #879aba; font-size: 12px; }
.chat-send { display: grid; place-items: center; width: 37px; height: 37px; flex: none; padding: 0; border: 1px solid #c8d8ff66; border-radius: 10px; color: #16243b; background: linear-gradient(130deg, #a6e7ff, #c3b2ff); cursor: pointer; }
.chat-send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-privacy { margin: 9px 0 0; text-align: center; color: #8da0bd; font: 400 9px/1.5 var(--sans); }
.chat-status { margin: 0; color: #b8c7e1; font: 400 10px/1.5 var(--sans); }
.chat-status:not(:empty) { padding-bottom: 9px; }
@keyframes chat-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 640px) {
  .portfolio-chat-launcher { right: 16px; bottom: max(14px, env(safe-area-inset-bottom)); min-height: 45px; padding: 10px 14px; font-size: 11px; }
  .portfolio-chat { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); width: calc(100vw - 24px); height: min(660px, calc(100dvh - 24px)); max-height: calc(100dvh - 24px); border-radius: 20px; }
  .chat-header { padding: 17px 15px 14px; gap: 10px; }
  .chat-scope { padding-inline: 15px; }
  .chat-log { padding-inline: 15px; }
  .chat-starters { padding-inline: 15px; }
  .chat-compose { padding-inline: 15px; }
  .chat-message { max-width: 100%; }
  .chat-heading h2 { font-size: 15px; }
}
@media (max-height: 500px) {
  .chat-header { padding-block: 12px; }
  .chat-scope { padding-block: 7px; }
  .chat-starters { padding-bottom: 10px; gap: 5px; }
  .chat-starters button { min-height: 35px; padding-block: 7px; }
  .chat-compose { padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .portfolio-chat[open] { animation: none; }
  .portfolio-chat-launcher, .chat-starters button { transition: none; }
  .portfolio-chat-launcher:hover { transform: none; }
}
