/* Otto chat window. Styles the existing frosted panel (#panel) once otto-chat.js has
   filled it. Uses the page's design tokens and falls back to the same values. */
#panel.otto-chat {
  --oc-ink: var(--ink, #0d1b2e);
  --oc-mute: var(--mute, #56667c);
  --oc-blue: var(--blue, #17409e);
  --oc-sky: var(--sky, #2c5cc0);
  --oc-good: var(--good, #0f9d6c);
  --oc-line: var(--line, rgba(13, 27, 46, .1));
  --oc-display: var(--display, "Manrope", "SF Pro Display", -apple-system, "Helvetica Neue", Arial, sans-serif);
  --oc-body: var(--body, "DM Sans", "SF Pro Text", -apple-system, "Helvetica Neue", Arial, sans-serif);
  position: fixed;
  z-index: 70;
  right: calc(34px + env(safe-area-inset-right, 0px));
  bottom: calc(146px + env(safe-area-inset-bottom, 0px));
  width: min(384px, calc(100vw - 44px));
  height: min(580px, calc(100vh - 176px));
  height: min(580px, calc(100dvh - 176px));
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  box-sizing: border-box;
  color: var(--oc-ink);
  font: 400 15px/1.45 var(--oc-body);
  background: rgba(255, 255, 255, .84);
  border: 1px solid var(--glass-edge, rgba(255, 255, 255, .85));
  border-radius: 26px;
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow: 0 34px 60px -30px rgba(16, 28, 40, .55), inset 0 1px 0 rgba(255, 255, 255, .9);
  animation: oc-in .28s cubic-bezier(.2, .8, .2, 1);
}
#panel.otto-chat[hidden] { display: none; }
#panel.otto-chat *, #panel.otto-chat *::before, #panel.otto-chat *::after { box-sizing: border-box; }
@keyframes oc-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* header */
.otto-chat .oc-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 16px; border-bottom: 1px solid var(--oc-line); flex: none; }
.otto-chat .oc-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; background: linear-gradient(180deg, #fff, #dbe6f3); flex: none; }
.otto-chat .oc-who { display: grid; gap: 1px; min-width: 0; margin-right: auto; }
.otto-chat .oc-who b { font: 700 16px/1.2 var(--oc-display); letter-spacing: -.01em; color: var(--oc-ink); }
.otto-chat .oc-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; line-height: 1.3; color: var(--oc-mute); white-space: nowrap; }
.otto-chat .oc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--oc-good); flex: none; }
.otto-chat .oc-icon { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: rgba(13, 27, 46, .07); color: var(--oc-ink); cursor: pointer; flex: none; transition: background .2s ease; }
.otto-chat .oc-icon svg { width: 16px; height: 16px; }

/* conversation */
.otto-chat .oc-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.otto-chat .oc-row { display: flex; }
.otto-chat .oc-me { justify-content: flex-end; }
.otto-chat .oc-bubble { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.42; white-space: pre-wrap; overflow-wrap: anywhere; }
.otto-chat .oc-otto .oc-bubble { background: #fff; color: var(--oc-ink); border: 1px solid var(--oc-line); border-bottom-left-radius: 6px; }
.otto-chat .oc-me .oc-bubble { background: var(--oc-blue); color: #fff; border-bottom-right-radius: 6px; }
.otto-chat .oc-alert { align-self: center; max-width: 92%; padding: 8px 12px; border-radius: 12px; background: rgba(13, 27, 46, .06); color: var(--oc-ink); font-size: 13.5px; line-height: 1.4; text-align: center; }

/* typing dots while the reply is on its way */
.otto-chat .oc-typing { display: inline-flex; align-items: center; gap: 5px; min-height: 40px; }
.otto-chat .oc-typing::before, .otto-chat .oc-typing::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--oc-sky); animation: oc-blink 1.1s ease-in-out infinite; }
.otto-chat .oc-typing::after { animation-delay: .25s; }
@keyframes oc-blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

/* starters */
.otto-chat .oc-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 4px; flex: none; }
.otto-chat .oc-chips[hidden] { display: none; }
.otto-chat .oc-chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(23, 64, 158, .35); background: rgba(255, 255, 255, .7); color: var(--oc-blue); font: 600 13px/1 var(--oc-body); cursor: pointer; white-space: nowrap; transition: background .2s ease, color .2s ease; }

/* input */
.otto-chat .oc-form { display: flex; align-items: flex-end; gap: 8px; margin: 8px 12px 0; padding: 6px 6px 6px 14px; border-radius: 22px; background: #fff; border: 1px solid var(--oc-line); flex: none; }
.otto-chat .oc-form:focus-within { border-color: var(--oc-blue); box-shadow: 0 0 0 3px rgba(23, 64, 158, .16); }
.otto-chat .oc-input { flex: 1 1 auto; min-width: 0; height: 36px; max-height: 104px; padding: 7px 0; margin: 0; border: 0; outline: 0; resize: none; background: none; color: var(--oc-ink); font: 400 16px/1.35 var(--oc-body); }
.otto-chat .oc-input::placeholder { color: var(--oc-mute); opacity: 1; }
.otto-chat .oc-send { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--oc-blue); color: #fff; cursor: pointer; flex: none; transition: background .2s ease, opacity .2s ease; }
.otto-chat .oc-send svg { width: 16px; height: 16px; }
.otto-chat .oc-send:disabled { opacity: .45; cursor: default; }
.otto-chat .oc-note { margin: 0; padding: 8px 16px 12px; font-size: 12px; line-height: 1.35; color: var(--oc-mute); text-align: center; flex: none; }

.otto-chat .oc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* keyboard focus */
.otto-chat .oc-icon:focus-visible, .otto-chat .oc-chip:focus-visible, .otto-chat .oc-send:focus-visible, .otto-chat .oc-log:focus-visible { outline: 2px solid var(--oc-blue); outline-offset: 2px; }
.otto-chat .oc-log:focus-visible { outline-offset: -2px; }
#launch:focus-visible { outline: 2px solid var(--blue, #17409e); outline-offset: 8px; border-radius: 50%; }

@media (hover: hover) {
  .otto-chat .oc-icon:hover { background: rgba(13, 27, 46, .14); }
  .otto-chat .oc-chip:hover { background: var(--oc-blue); color: #fff; }
  .otto-chat .oc-send:not(:disabled):hover { background: var(--blue-deep, #0c2a6e); }
}

/* tablets: the page moves the launcher up to clear the bottom tab bar */
@media (max-width: 820px) {
  #panel.otto-chat { right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(184px + env(safe-area-inset-bottom, 0px)); height: min(560px, calc(100vh - 204px)); height: min(560px, calc(100dvh - 204px)); }
}

/* phones: the window takes the lower part of the screen and the launcher steps aside */
@media (max-width: 520px) {
  #panel.otto-chat {
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    bottom: calc(8px + env(safe-area-inset-bottom, 0px) + var(--oc-kb, 0px));
    width: auto;
    height: min(600px, calc(var(--oc-vh, 100dvh) - 16px - env(safe-area-inset-bottom, 0px)));
    min-height: 0;
    z-index: 75;
    border-radius: 22px;
    background: rgba(255, 255, 255, .93);
  }
  .otto-chat-open .otto-root { display: none; }
  .otto-chat .oc-icon { width: 40px; height: 40px; }
  .otto-chat .oc-chip { height: 36px; }
  .otto-chat .oc-send { width: 40px; height: 40px; }
  .otto-chat .oc-input { height: 40px; padding: 9px 0; }
}

@media (prefers-reduced-motion: reduce) {
  #panel.otto-chat { animation: none; }
  .otto-chat .oc-typing::before, .otto-chat .oc-typing::after { animation: none; opacity: .7; }
}
