/* Ask the Book widget styles.
 * Theme from the page with: --askbook-accent, --askbook-bg, --askbook-text, --askbook-muted, --askbook-font
 * Text sizes: 18px desktop, 17px phone, never below 16px.
 */
.askbook-launcher, .askbook-panel, .askbook-inline {
  --ab-accent: var(--askbook-accent, #1f5fbf);
  --ab-bg: var(--askbook-bg, #ffffff);
  --ab-text: var(--askbook-text, #1b1f24);
  --ab-muted: var(--askbook-muted, #4a5260);
  --ab-line: rgba(0, 0, 0, 0.16);
  font-family: var(--askbook-font, inherit);
  font-size: 18px;
  line-height: 1.5;
  color: var(--ab-text);
}
.askbook-launcher *, .askbook-panel *, .askbook-inline * { box-sizing: border-box; }
.askbook-launcher, .askbook-panel, .askbook-inline { box-sizing: border-box; }

.askbook-launcher {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 99990;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--ab-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  transition: transform 0.15s ease;
}
.askbook-launcher:hover { transform: translateY(-2px); }
.askbook-launcher:focus-visible, .askbook-panel button:focus-visible, .askbook-panel textarea:focus-visible,
.askbook-inline button:focus-visible, .askbook-inline textarea:focus-visible, .askbook-panel a:focus-visible {
  outline: 3px solid var(--ab-accent);
  outline-offset: 2px;
}
.askbook-launcher:focus-visible { outline-color: var(--ab-text); }

.askbook-panel {
  position: fixed;
  right: 16px;
  bottom: 84px;
  z-index: 99991;
  display: flex;
  flex-direction: column;
  width: 420px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 110px);
  background: var(--ab-bg);
  border: 1px solid var(--ab-line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.askbook-panel[hidden] { display: none; }

.askbook-inline {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 24px auto;
  background: var(--ab-bg);
  border: 1px solid var(--ab-line);
  border-radius: 14px;
  overflow: hidden;
}
.askbook-inline .askbook-log { max-height: 480px; min-height: 160px; }

.askbook-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ab-accent);
  color: #fff;
}
.askbook-title { margin: 0; font: inherit; font-weight: 700; font-size: 18px; line-height: 1.3; color: #fff; }
.askbook-tools { display: flex; gap: 4px; flex-shrink: 0; }
.askbook-link {
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 16px;
  text-decoration: underline;
  cursor: pointer;
}
.askbook-head .askbook-link:focus-visible { outline-color: #fff; }

.askbook-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.askbook-msg {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.askbook-text { white-space: pre-wrap; }
.askbook-bot { align-self: flex-start; background: rgba(0, 0, 0, 0.06); }
.askbook-user { align-self: flex-end; background: var(--ab-accent); color: #fff; }
.askbook-error { border: 2px solid #b3261e; background: transparent; }
.askbook-wait { color: var(--ab-muted); font-style: italic; }
.askbook-sources { margin-top: 8px; font-size: 16px; line-height: 1.4; color: var(--ab-muted); }
.askbook-sources-label { font-weight: 700; }
.askbook-source { margin-right: 6px; }
.askbook-loginlink { display: inline-block; margin-top: 8px; color: var(--ab-accent); font-weight: 700; }

.askbook-starters { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 8px; }
.askbook-starters:empty { display: none; }
.askbook-chip {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--ab-accent);
  border-radius: 12px;
  background: var(--ab-bg);
  color: var(--ab-accent);
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.askbook-chip:hover { background: rgba(0, 0, 0, 0.05); }

.askbook-form { display: flex; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--ab-line); }
.askbook-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  max-height: 140px;
  padding: 8px 12px;
  border: 1px solid var(--ab-muted);
  border-radius: 10px;
  background: var(--ab-bg);
  color: var(--ab-text);
  font: inherit;
  resize: none;
}
.askbook-send {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--ab-accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.askbook-send:disabled { opacity: 0.55; cursor: default; }
.askbook-note { margin: 0; padding: 0 16px 10px; font-size: 16px; line-height: 1.4; color: var(--ab-muted); }

@media (max-width: 600px) {
  .askbook-launcher, .askbook-panel, .askbook-inline { font-size: 17px; }
  .askbook-panel {
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .askbook-msg { max-width: 100%; }
  html.askbook-open { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .askbook-launcher { transition: none; }
  .askbook-launcher:hover { transform: none; }
}
