/* ══ THE STORY SHOP — BOOKMARK ══
   Prefixed .bs- throughout so nothing collides with the theme's own CSS. */

.bs-root {
  --bs-navy: #1C2B4A;
  --bs-navy-lift: #24355A;
  --bs-white: #FFFFFF;
  --bs-surface: #F7F7F5;
  --bs-gray: #6B7280;
  --bs-gold: #B8956A;
  --bs-gold-soft: rgba(184, 149, 106, .14);
  --bs-border: #E5E5E2;
  --bs-r: 10px;
  --bs-shadow: 0 18px 48px -12px rgba(28, 43, 74, .28), 0 4px 12px rgba(28, 43, 74, .06);
  --bs-ease: cubic-bezier(.16, 1, .3, 1);
  --bs-sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --bs-serif: 'Cormorant Garamond', Georgia, serif;
  --bs-mono: 'DM Mono', ui-monospace, monospace;
  font-family: var(--bs-sans);
}
.bs-root *, .bs-root *::before, .bs-root *::after { box-sizing: border-box; }

/* ── Launcher ───────────────────────────────── */
.bs-bubble {
  position: fixed; bottom: 24px; right: 24px; z-index: 9990;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--bs-navy); color: var(--bs-white);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--bs-shadow);
  animation: bs-rise .5s var(--bs-ease) both;
  transition: transform .3s var(--bs-ease), opacity .22s, background .22s;
}
.bs-bubble:hover { transform: translateY(-2px) scale(1.05); background: var(--bs-navy-lift); }
.bs-bubble:active { transform: scale(.97); }
.bs-bubble:focus-visible { outline: 2px solid var(--bs-gold); outline-offset: 4px; }
.bs-bubble.bs-hidden { opacity: 0; pointer-events: none; transform: scale(.7); }

@keyframes bs-rise { from { opacity: 0; transform: translateY(14px) scale(.9); } }

/* One quiet ring on arrival — noticed, not nagging */
.bs-bubble::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 1.5px solid var(--bs-gold); opacity: 0;
  animation: bs-ring 2.6s var(--bs-ease) .9s 2;
}
@keyframes bs-ring {
  0% { opacity: .7; transform: scale(1); }
  70%, 100% { opacity: 0; transform: scale(1.32); }
}

/* The sparkle breathes so the mark reads as alive, not decorative */
.bs-spark { transform-origin: center; animation: bs-twinkle 4.5s ease-in-out infinite; }
@keyframes bs-twinkle {
  0%, 62%, 100% { opacity: .55; transform: scale(.86); }
  74% { opacity: 1; transform: scale(1.12); }
}

/* ── Greeting tab ───────────────────────────── */
.bs-hello {
  position: fixed; bottom: 38px; right: 92px; z-index: 9989;
  background: var(--bs-white); color: var(--bs-navy);
  border: 1px solid var(--bs-border); border-radius: var(--bs-r);
  padding: 10px 14px; font-size: 13px; line-height: 1.45; max-width: 210px;
  box-shadow: 0 8px 24px -8px rgba(28, 43, 74, .22);
  cursor: pointer; text-align: left;
  animation: bs-hello-in .55s var(--bs-ease) 1.4s both;
  transition: opacity .25s, transform .25s var(--bs-ease);
}
.bs-hello::after {
  content: ''; position: absolute; right: -6px; bottom: 18px;
  width: 10px; height: 10px; background: var(--bs-white);
  border-right: 1px solid var(--bs-border); border-top: 1px solid var(--bs-border);
  transform: rotate(45deg);
}
.bs-hello b { display: block; font-family: var(--bs-serif); font-size: 16px; font-weight: 600; margin-bottom: 1px; }
.bs-hello.bs-gone { opacity: 0; transform: translateX(8px); pointer-events: none; }
@keyframes bs-hello-in { from { opacity: 0; transform: translateX(12px); } }

/* ── Panel ──────────────────────────────────── */
.bs-panel {
  position: fixed; bottom: 24px; right: 24px; z-index: 9991;
  width: 396px; max-width: calc(100vw - 32px);
  height: 596px; max-height: calc(100vh - 48px);
  background: var(--bs-white);
  border: 1px solid var(--bs-border); border-radius: var(--bs-r);
  box-shadow: var(--bs-shadow);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; visibility: hidden;
  transform: translateY(16px) scale(.97); transform-origin: bottom right;
  transition: opacity .3s ease, transform .38s var(--bs-ease), visibility .38s;
}
.bs-panel.bs-open { opacity: 1; visibility: visible; transform: none; }

.bs-head {
  background: var(--bs-navy); color: var(--bs-white);
  padding: 15px 16px; display: flex; align-items: center; gap: 11px; flex-shrink: 0;
  position: relative;
}
.bs-head::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--bs-gold), transparent); opacity: .5;
}
.bs-mark {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: rgba(255, 255, 255, .09);
  display: flex; align-items: center; justify-content: center; color: var(--bs-gold);
}
.bs-head-title { font-family: var(--bs-serif); font-size: 20px; font-weight: 600; line-height: 1.15; }
.bs-head-sub {
  font-family: var(--bs-mono); font-size: 9.5px; letter-spacing: .13em;
  text-transform: uppercase; color: rgba(255, 255, 255, .48); margin-top: 3px;
}
.bs-close {
  margin-left: auto; background: none; border: none; color: rgba(255,255,255,.5);
  cursor: pointer; padding: 7px; line-height: 0; border-radius: 6px;
  transition: color .2s, background .2s;
}
.bs-close:hover { color: var(--bs-white); background: rgba(255,255,255,.09); }
.bs-close:focus-visible { outline: 2px solid var(--bs-gold); outline-offset: 1px; }

/* ── Messages ───────────────────────────────── */
.bs-body { flex: 1; overflow-y: auto; padding: 18px 16px; scroll-behavior: smooth; }
.bs-body::-webkit-scrollbar { width: 5px; }
.bs-body::-webkit-scrollbar-thumb { background: var(--bs-border); border-radius: 3px; }
.bs-body::-webkit-scrollbar-thumb:hover { background: var(--bs-gray); }

.bs-msg { margin-bottom: 13px; display: flex; animation: bs-msg-in .42s var(--bs-ease) both; }
@keyframes bs-msg-in { from { opacity: 0; transform: translateY(9px); } }
.bs-msg-in { justify-content: flex-start; }
.bs-msg-out { justify-content: flex-end; }

.bs-bubble-txt {
  max-width: 87%; padding: 11px 14px; font-size: 14px; line-height: 1.65;
  white-space: pre-wrap; word-wrap: break-word; border-radius: 12px;
}
.bs-msg-in  .bs-bubble-txt { background: var(--bs-surface); color: var(--bs-navy);
  border: 1px solid var(--bs-border); border-bottom-left-radius: 4px; }
.bs-msg-out .bs-bubble-txt { background: var(--bs-navy); color: var(--bs-white);
  border-bottom-right-radius: 4px; }
.bs-bubble-txt.bs-rtl { direction: rtl; text-align: right; }
.bs-bubble-txt strong { font-weight: 600; }
.bs-msg-in .bs-bubble-txt strong { color: var(--bs-navy); box-shadow: inset 0 -6px 0 var(--bs-gold-soft); }

/* ── Typing ─────────────────────────────────── */
.bs-typing { display: flex; gap: 5px; padding: 14px 15px; align-items: center; }
.bs-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--bs-gold);
  animation: bs-blink 1.25s infinite both; }
.bs-typing i:nth-child(2) { animation-delay: .16s; }
.bs-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes bs-blink { 0%,80%,100% { opacity: .2; transform: translateY(0); }
                      40% { opacity: 1; transform: translateY(-3px); } }

/* ── Book cards ─────────────────────────────── */
.bs-books { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; }
.bs-book {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; background: var(--bs-white);
  border: 1px solid var(--bs-border); border-radius: 9px;
  animation: bs-card-in .48s var(--bs-ease) both;
  transition: border-color .22s, transform .22s var(--bs-ease), box-shadow .22s;
}
.bs-book:nth-child(2) { animation-delay: .09s; }
.bs-book:nth-child(3) { animation-delay: .18s; }
@keyframes bs-card-in { from { opacity: 0; transform: translateY(10px); } }
.bs-book:hover {
  border-color: var(--bs-gold); transform: translateY(-2px);
  box-shadow: 0 8px 20px -10px rgba(28, 43, 74, .26);
}
.bs-book-img { width: 46px; height: 66px; object-fit: cover; border-radius: 4px;
  background: var(--bs-surface); display: block; }
.bs-book-info { min-width: 0; }
.bs-book-title { font-size: 13px; font-weight: 500; color: var(--bs-navy); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bs-book-title a { color: inherit; text-decoration: none; }
.bs-book-title a:hover { color: var(--bs-gold); }
.bs-book-price { font-family: var(--bs-mono); font-size: 12px; color: var(--bs-gray); margin-top: 4px; }

.bs-add {
  font-family: var(--bs-sans); font-size: 11px; font-weight: 500; letter-spacing: .03em;
  white-space: nowrap; padding: 7px 12px; cursor: pointer; border-radius: 6px;
  background: var(--bs-navy); color: var(--bs-white); border: 1px solid var(--bs-navy);
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}
.bs-add:hover:not(:disabled) { background: var(--bs-gold); border-color: var(--bs-gold); }
.bs-add:active:not(:disabled) { transform: scale(.95); }
.bs-add:focus-visible { outline: 2px solid var(--bs-gold); outline-offset: 2px; }
.bs-add.bs-added { background: var(--bs-gold); border-color: var(--bs-gold);
  animation: bs-pop .32s var(--bs-ease); }
@keyframes bs-pop { 50% { transform: scale(1.1); } }
.bs-add.bs-pre { background: transparent; color: var(--bs-gold); border-color: var(--bs-gold); }
.bs-add.bs-pre:hover { background: var(--bs-gold); color: var(--bs-white); }
.bs-add:disabled { background: transparent; color: var(--bs-gray);
  border-color: var(--bs-border); cursor: default; }

/* ── Composer ───────────────────────────────── */
.bs-foot { border-top: 1px solid var(--bs-border); padding: 12px; flex-shrink: 0; background: var(--bs-white); }
.bs-form { display: flex; gap: 8px; align-items: flex-end; }
.bs-input {
  flex: 1; resize: none; font-family: var(--bs-sans); font-size: 14px; line-height: 1.45;
  color: var(--bs-navy); background: var(--bs-surface);
  border: 1px solid var(--bs-border); border-radius: 9px; padding: 11px 13px;
  max-height: 96px; min-height: 42px; transition: border-color .2s, background .2s;
}
.bs-input:focus { outline: none; border-color: var(--bs-gold); background: var(--bs-white); }
.bs-input::placeholder { color: var(--bs-gray); }
.bs-send {
  width: 42px; height: 42px; flex-shrink: 0; cursor: pointer; border-radius: 9px;
  background: var(--bs-navy); color: var(--bs-white); border: none;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
}
.bs-send:hover:not(:disabled) { background: var(--bs-gold); }
.bs-send:active:not(:disabled) { transform: scale(.94); }
.bs-send:disabled { background: var(--bs-border); color: var(--bs-gray); cursor: default; }
.bs-send:focus-visible { outline: 2px solid var(--bs-gold); outline-offset: 2px; }

.bs-note { font-size: 10.5px; color: var(--bs-gray); text-align: center; margin: 9px 0 0; line-height: 1.45; }

/* ── Openers ────────────────────────────────── */
.bs-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.bs-chip {
  font-family: var(--bs-sans); font-size: 12.5px; color: var(--bs-navy);
  background: var(--bs-white); border: 1px solid var(--bs-border); border-radius: 8px;
  padding: 9px 12px; cursor: pointer; text-align: left;
  animation: bs-msg-in .42s var(--bs-ease) both;
  transition: border-color .2s, background .2s, transform .18s var(--bs-ease);
}
.bs-chip:nth-child(1) { animation-delay: .06s; }
.bs-chip:nth-child(2) { animation-delay: .13s; }
.bs-chip:nth-child(3) { animation-delay: .2s; }
.bs-chip:hover { border-color: var(--bs-gold); background: var(--bs-surface); transform: translateX(3px); }
.bs-chip:focus-visible { outline: 2px solid var(--bs-gold); outline-offset: 2px; }

@media (max-width: 480px) {
  .bs-panel { bottom: 0; right: 0; width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .bs-bubble { bottom: 18px; right: 18px; }
  .bs-hello { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bs-root *, .bs-root *::before, .bs-root *::after {
    animation: none !important; transition-duration: .01ms !important;
  }
}
