:root {
  --blog-chat-gap: 10px;
  --blog-chat-clearance: calc(44px + 2 * var(--blog-chat-gap) + env(safe-area-inset-bottom, 0px));
}

/* Keep the last line of the article and the footer above the floating button. */
html.blog-chat-ready { height: 100%; overflow: hidden; background: var(--paper); }
html.blog-chat-ready body {
  min-height: 0;
  height: calc(100% - var(--blog-chat-clearance));
  height: calc(100dvh - var(--blog-chat-clearance));
  overflow-y: auto;
}

#blog-chat {
  position: fixed;
  z-index: 20;
  top: var(--blog-chat-view-top, 0px);
  right: max(var(--blog-chat-gap), env(safe-area-inset-right, 0px));
  box-sizing: border-box;
  width: 392px;
  height: 100%;
  height: var(--blog-chat-view-height, 100dvh);
  max-width: calc(100% - 2 * var(--blog-chat-gap) - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  padding: calc(var(--blog-chat-gap) + env(safe-area-inset-top, 0px)) 0 calc(var(--blog-chat-gap) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
  font-family: var(--type);
}
#blog-chat[hidden], #blog-chat [hidden] { display: none !important; }
#blog-chat-launch, #blog-chat-panel { pointer-events: auto; }
#blog-chat-launch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 2px 7px #0002;
  cursor: pointer;
  font: 700 15px/1 var(--type);
}
#blog-chat-launch:hover { box-shadow: 0 3px 11px #0004; }
#blog-chat :is(button, a):focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
#blog-chat-panel {
  width: min(392px, 100%);
  max-width: 100%;
  height: min(560px, 100%);
  min-height: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 10px 38px #0003;
}
.blog-chat-toolbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 4px 16px;
  background: var(--ink);
  color: var(--paper);
}
#blog-chat-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  line-height: 1.3;
}
.blog-chat-toolbar :is(button, a) {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.blog-chat-toolbar :is(button, a):hover { background: color-mix(in srgb, var(--paper) 16%, transparent); }
#blog-chat-panel iframe { display: block; flex: 1; width: 100%; min-height: 0; border: 0; }
