/* Copilot floating widget — AllScience platform
   Loads on any page: <link rel="stylesheet" href="/css/copilot-widget.css">
                      <script src="/js/copilot-widget.js" defer></script>
   Widget injects itself into document.body on DOMContentLoaded.
*/
.cp-btn{
  position:fixed;bottom:20px;right:20px;width:56px;height:56px;border-radius:50%;
  background:linear-gradient(135deg,#315f72,#315f72);color:#fff;border:none;
  box-shadow:0 8px 24px rgba(49, 95, 114, .35);cursor:pointer;font-size:1.4rem;
  display:grid;place-items:center;z-index:9998;transition:transform .18s, box-shadow .18s;
  font-family:'Inter',system-ui,sans-serif;
}
.cp-btn:hover{transform:translateY(-2px) scale(1.04);box-shadow:0 12px 28px rgba(49, 95, 114, .5);}
.cp-btn:focus{outline:2px solid #fff;outline-offset:3px;}
.cp-btn .cp-badge{
  position:absolute;top:-4px;right:-4px;background:#047857;color:#fff; /* a11y: was #10b981 (2.53:1 vs white text); #047857 gives 5.4:1 */
  font-size:.55rem;padding:.1rem .4rem;border-radius:999px;font-weight:700;
  box-shadow:0 2px 6px rgba(0,0,0,.2);font-family:inherit;
}

.cp-panel{
  position:fixed;bottom:88px;right:20px;width:360px;max-width:calc(100vw - 40px);
  max-height:min(560px, calc(100vh - 120px));background:#0f172a;color:#e2e8f0;
  border:1px solid rgba(148,163,184,.15);border-radius:16px;
  box-shadow:0 24px 64px rgba(0,0,0,.45);overflow:hidden;display:none;flex-direction:column;
  font-family:'Inter',system-ui,sans-serif;z-index:9999;
}
.cp-panel.open{display:flex;animation:cp-in .22s ease-out;}
@keyframes cp-in{from{transform:translateY(8px);opacity:0;}to{transform:translateY(0);opacity:1;}}

.cp-head{
  padding:.9rem 1.1rem;border-bottom:1px solid rgba(148,163,184,.15);
  display:flex;justify-content:space-between;align-items:center;
  background:linear-gradient(135deg,rgba(49, 95, 114, .15),rgba(49, 95, 114, .08));
}
.cp-head h3{margin:0;font-size:.95rem;font-weight:700;color:#f1f5f9;}
.cp-head .sub{font-size:.7rem;color:#94a3b8;margin-top:.1rem;}
.cp-head button{background:transparent;border:none;color:#94a3b8;cursor:pointer;font-size:1.3rem;padding:0 .3rem;line-height:1;}
.cp-head button:hover{color:#e2e8f0;}

.cp-msgs{
  flex:1;overflow-y:auto;padding:1rem;display:flex;flex-direction:column;gap:.75rem;
  scroll-behavior:smooth;
}
.cp-msgs::-webkit-scrollbar{width:6px;}
.cp-msgs::-webkit-scrollbar-thumb{background:rgba(148,163,184,.2);border-radius:3px;}

.cp-msg{
  max-width:85%;padding:.65rem .9rem;border-radius:12px;font-size:.87rem;line-height:1.55;
  white-space:pre-wrap;word-wrap:break-word;
}
.cp-msg.user{align-self:flex-end;background:linear-gradient(135deg,#315f72,#315f72);color:#fff;border-bottom-right-radius:4px;}
.cp-msg.bot{align-self:flex-start;background:rgba(148,163,184,.08);border:1px solid rgba(148,163,184,.12);color:#e2e8f0;border-bottom-left-radius:4px;}
.cp-msg.bot .demo{font-size:.68rem;color:#f5c06c;text-transform:uppercase;letter-spacing:.04em;font-weight:700;margin-bottom:.25rem;display:block;}

.cp-suggestions{display:flex;flex-wrap:wrap;gap:.4rem;margin-top:.3rem;}
.cp-suggestions button{
  background:rgba(49, 95, 114, .12);color:#cfc7bb;border:1px solid rgba(49, 95, 114, .3);
  padding:.3rem .7rem;border-radius:999px;font-size:.74rem;cursor:pointer;font:inherit;
}
.cp-suggestions button:hover{background:rgba(49, 95, 114, .22);}

.cp-form{
  padding:.75rem .9rem;border-top:1px solid rgba(148,163,184,.15);
  display:flex;gap:.5rem;align-items:flex-end;background:#0a0f1f;
}
.cp-form textarea{
  flex:1;resize:none;padding:.55rem .75rem;background:rgba(30,41,59,.6);color:#e2e8f0;
  border:1px solid rgba(148,163,184,.18);border-radius:8px;font:inherit;font-size:.87rem;
  min-height:36px;max-height:100px;line-height:1.4;
}
.cp-form textarea:focus{outline:none;border-color:#315f72;}
.cp-form button{
  background:linear-gradient(135deg,#315f72,#315f72);color:#fff;border:none;
  padding:.55rem .9rem;border-radius:8px;cursor:pointer;font:inherit;font-weight:600;font-size:.85rem;
}
.cp-form button:disabled{opacity:.5;cursor:not-allowed;}

.cp-status{font-size:.68rem;color:#94a3b8;padding:.4rem 1rem;background:rgba(15,23,42,.8);border-top:1px solid rgba(148,163,184,.1);text-align:center;}
.cp-status.demo{color:#f5c06c;}

@media (max-width:520px){
  .cp-panel{width:calc(100vw - 20px);right:10px;bottom:78px;}
  .cp-btn{right:14px;bottom:14px;}
}

/* Light-mode override for pages that force light palette (WonderPress) */
body.wp-light .cp-panel, .wp-theme .cp-panel{
  background:#ffffff;color:#1e293b;border-color:#e2e8f0;
}
body.wp-light .cp-msg.bot, .wp-theme .cp-msg.bot{background:#f1f5f9;border-color:#e2e8f0;color:#1e293b;}
body.wp-light .cp-form, .wp-theme .cp-form{background:#f8fafc;}
body.wp-light .cp-form textarea, .wp-theme .cp-form textarea{background:#ffffff;color:#1e293b;border-color:#cbd5e1;}
body.wp-light .cp-head, .wp-theme .cp-head{background:linear-gradient(135deg,rgba(49, 95, 114, .1),rgba(49, 95, 114, .05));}
body.wp-light .cp-head h3, .wp-theme .cp-head h3{color:#0f172a;}

/* ── Sidebar CopilotPanel (Session 7) ── */

#bc-copilot-panel {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.78rem;
  color: #e2e8f0;
  background: #0a0f1f;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Header / usage badge */
.bc-copilot-header {
  padding: 0.35rem 0.5rem 0.25rem;
  border-bottom: 1px solid rgba(148,163,184,.12);
}
.bc-copilot-usage-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.02em;
}
.bc-copilot-usage-badge.bc-copilot-usage-unlimited {
  color: #34d399;
}

/* Tabs */
.bc-copilot-tabs {
  display: flex;
  gap: 0.2rem;
  padding: 0.35rem 0.4rem;
  background: rgba(255,255,255,.02);
  border-bottom: 1px solid rgba(148,163,184,.1);
  flex-wrap: nowrap;
  overflow-x: auto;
}
.bc-copilot-tab {
  flex: 1;
  padding: 0.25rem 0.3rem;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 999px;
  background: transparent;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.bc-copilot-tab:hover {
  background: rgba(49, 95, 114, .12);
  color: #cfc7bb;
  border-color: rgba(49, 95, 114, .4);
}
.bc-copilot-tab.active {
  background: #315f72;
  color: #fff;
  border-color: #315f72;
}

/* Panes */
.bc-copilot-pane {
  padding: 0.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  max-height: 480px;
}

/* Action groups */
.bc-copilot-action-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(148,163,184,.08);
}
.bc-copilot-action-group:last-of-type {
  border-bottom: none;
}

/* Labels and hints */
.bc-copilot-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bc-copilot-hint {
  font-size: 0.62rem;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}

/* Inputs */
.bc-copilot-input {
  width: 100%;
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
  background: rgba(30,41,59,.5);
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 5px;
  color: #e2e8f0;
  font-family: inherit;
  box-sizing: border-box;
}
.bc-copilot-input:focus {
  outline: none;
  border-color: #315f72;
}
.bc-copilot-input-sm {
  width: 72px;
  padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
  background: rgba(30,41,59,.5);
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 5px;
  color: #e2e8f0;
  font-family: inherit;
}
.bc-copilot-input-sm:focus { outline: none; border-color: #315f72; }

.bc-copilot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.bc-copilot-textarea-sm {
  width: 100%;
  padding: 0.3rem 0.45rem;
  font-size: 0.72rem;
  background: rgba(30,41,59,.5);
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 5px;
  color: #e2e8f0;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
  min-height: 44px;
}
.bc-copilot-textarea-sm:focus { outline: none; border-color: #315f72; }

/* Buttons */
.bc-copilot-btn-primary {
  width: 100%;
  padding: 0.35rem 0.5rem;
  background: #315f72;
  border: none;
  border-radius: 5px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.bc-copilot-btn-primary:hover { background: #244b5b; }
.bc-copilot-btn-primary:disabled { opacity: 0.5; cursor: wait; }

.bc-copilot-btn-secondary {
  width: 100%;
  padding: 0.3rem 0.5rem;
  background: transparent;
  border: 1px solid rgba(49, 95, 114, .4);
  border-radius: 5px;
  color: #f5c06c;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.bc-copilot-btn-secondary:hover {
  background: rgba(49, 95, 114, .12);
  border-color: #315f72;
}
.bc-copilot-btn-secondary:disabled { opacity: 0.5; cursor: wait; }

.bc-copilot-btn-stop {
  padding: 0.2rem 0.5rem;
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.4);
  border-radius: 4px;
  color: #fca5a5;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-left: 0.35rem;
}
.bc-copilot-btn-stop:hover { background: rgba(239,68,68,.25); }

/* Status / streaming output */
.bc-copilot-status {
  font-size: 0.65rem;
  color: #94a3b8;
  min-height: 1rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.bc-copilot-error {
  color: #fca5a5;
}

.bc-copilot-stream-output {
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 0.68rem;
  color: #cbd5e1;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 5px;
  padding: 0.4rem 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

/* Spinner */
@keyframes bc-copilot-spin {
  to { transform: rotate(360deg); }
}
.bc-copilot-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(148,163,184,.2);
  border-top-color: #315f72;
  border-radius: 50%;
  animation: bc-copilot-spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Result cards */
.bc-copilot-cards {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.bc-copilot-card {
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  background: rgba(148,163,184,.08);
  border: 1px solid rgba(148,163,184,.15);
  border-radius: 5px;
  color: #e2e8f0;
  font-size: 0.7rem;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.12s, border-color 0.12s;
}
.bc-copilot-card:hover {
  background: rgba(49, 95, 114, .14);
  border-color: rgba(49, 95, 114, .45);
}

/* Story Bible accordion */
.bc-copilot-accordion {
  border: 1px solid rgba(148,163,184,.12);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}
.bc-copilot-accordion-summary {
  padding: 0.35rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: #cfc7bb;
  cursor: pointer;
  background: rgba(49, 95, 114, .08);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.bc-copilot-accordion-summary::before {
  content: '\25B6';
  font-size: 0.55rem;
  transition: transform 0.15s;
  flex-shrink: 0;
}
details[open] .bc-copilot-accordion-summary::before {
  transform: rotate(90deg);
}
.bc-copilot-accordion-list {
  margin: 0;
  padding: 0.35rem 0.6rem 0.35rem 1rem;
  list-style: disc;
  font-size: 0.68rem;
  color: #94a3b8;
  line-height: 1.6;
}
.bc-copilot-accordion-list li + li {
  margin-top: 0.2rem;
}
.bc-copilot-accordion-list strong {
  color: #e2e8f0;
}
.bc-copilot-dim {
  color: #64748b;
  font-size: 0.65rem;
}

/* Dim helper text */

