#demiurg-chat {
  --dg-blue: #152f57;
  --dg-ink: #162744;
  --dg-light: #f1f5fa;
  position: fixed;
  z-index: 9999;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  color: var(--dg-ink);
  font: 400 1rem/1.45 system-ui, sans-serif;
}
#demiurg-chat * { box-sizing: border-box; }
#demiurg-chat [hidden] { display: none; }
#demiurg-chat button {
  margin: 0;
  border: 0;
  border-radius: .6rem;
  background: var(--dg-blue);
  color: white;
  font: 650 .875rem/1.25 system-ui, sans-serif;
  letter-spacing: normal;
  text-transform: none;
  padding: .65rem .85rem;
  cursor: pointer;
}
#demiurg-chat :focus-visible { outline: 3px solid #417bdd; outline-offset: 2px; }
#demiurg-chat .dg-launch { padding: .9rem 1.15rem; border-radius: 2rem; box-shadow: 0 5px 18px #152f5740; }
#demiurg-chat .dg-panel {
  position: absolute;
  bottom: calc(100% + .65rem);
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(25rem, calc(100vw - 2rem));
  height: min(37rem, calc(100dvh - 5.5rem));
  overflow: hidden;
  background: white;
  border: 1px solid #d8e2ef;
  border-radius: 1rem;
  box-shadow: 0 14px 45px #152f5740;
}
#demiurg-chat .dg-panel[hidden] { display: none; }
#demiurg-chat .dg-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--dg-blue);
  color: white;
}
#demiurg-chat h2 { margin: 0; color: inherit; font: 700 1rem/1.35 system-ui, sans-serif; }
#demiurg-chat .dg-close { background: #ffffff20; font-size: 1.4rem; padding: .25rem .6rem; }
#demiurg-chat .dg-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .75rem; }
#demiurg-chat .dg-message {
  margin: 0 .8rem .55rem 0;
  padding: .7rem .8rem;
  border-radius: .75rem;
  background: var(--dg-light);
  white-space: pre-line;
  overflow-wrap: anywhere;
}
#demiurg-chat .dg-user { margin: 0 0 .55rem 1.5rem; background: #e0ebff; }
#demiurg-chat .dg-book { display: block; margin-top: .65rem; text-align: left; }
#demiurg-chat .dg-call { display: inline-block; margin-top: .5rem; color: var(--dg-blue); font-size: .875rem; text-decoration: underline; }
#demiurg-chat .dg-topics, #demiurg-chat .dg-form {
  flex: none;
  display: flex;
  gap: .4rem;
  padding: .5rem .75rem;
  margin: 0;
  border-top: 1px solid #e5edf5;
}
#demiurg-chat .dg-topics { flex-wrap: wrap; }
#demiurg-chat .dg-topics button { background: var(--dg-light); color: var(--dg-blue); padding: .45rem .55rem; }
#demiurg-chat .dg-form input {
  flex: 1;
  min-width: 0;
  width: auto;
  margin: 0;
  background: white;
  color: var(--dg-ink);
  border: 1px solid #b6c6d8;
  border-radius: .55rem;
  padding: .55rem;
  font: 400 1rem/1.25 system-ui, sans-serif;
}
