.sai-backdrop { display: none; }

@media (max-width: 480px) {
  .sai-backdrop {
    display: block; position: fixed; inset: 0; z-index: 99998;
    background: rgba(20,40,70,.35); opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
  }
  .sai-backdrop.show { opacity: 1; pointer-events: auto; }
}

/* Schnorr AI Assistant — front-end chat, branded to schnorr.com */
#schnorr-ai-root, #schnorr-ai-inline { --sai-radius: 14px; }

.sai-launch {
  position: fixed; bottom: 24px; z-index: 99998;
  display: flex; align-items: center; gap: 10px;
  background: var(--sai-primary); color: #fff;
  border: none; cursor: pointer;
  padding: 13px 20px 13px 16px; border-radius: 50px;
  font: 600 15px/1 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  box-shadow: 0 8px 26px rgba(28,91,184,.38);
  transition: transform .15s ease, box-shadow .15s ease;
}
.sai-launch:hover,
.sai-launch:focus {
  background: var(--sai-dark);   /* darker blue on hover, never pink */
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(28,91,184,.45);
}
#schnorr-ai-root[data-pos="right"] .sai-launch { right: 24px; }
#schnorr-ai-root[data-pos="left"]  .sai-launch { left: 24px; }
.sai-launch svg { width: 22px; height: 22px; }
.sai-launch .sai-launch-label { white-space: nowrap; }

.sai-panel {
  position: fixed; bottom: 24px; z-index: 99999;
  width: 388px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 48px);
  background: #fff; border-radius: var(--sai-radius);
  box-shadow: 0 24px 60px rgba(20,40,70,.28);
  display: none; flex-direction: column; overflow: hidden;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
#schnorr-ai-root[data-pos="right"] .sai-panel { right: 24px; }
#schnorr-ai-root[data-pos="left"]  .sai-panel { left: 24px; }
.sai-panel.open { display: flex; animation: sai-in .18s ease; }
@keyframes sai-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.sai-head {
  background: linear-gradient(135deg, var(--sai-primary), var(--sai-dark));
  color: #fff; padding: 15px 16px; display: flex; align-items: center; gap: 12px;
}
.sai-head img { height: 26px; width: auto; }
.sai-head .sai-title { font-weight: 700; font-size: 15px; line-height: 1.1; white-space: nowrap; }
.sai-head .sai-badge {
  font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(255,255,255,.18); padding: 2px 8px; border-radius: 20px; margin-top: 3px; display: inline-block;
}
.sai-head .sai-newchat {
  margin-left: auto;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
  color: #fff; cursor: pointer; font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 20px; line-height: 1; white-space: nowrap;
  transition: background .12s;
}
.sai-head .sai-newchat:hover { background: rgba(255,255,255,.28); }
.sai-head .sai-close { margin-left: 8px; background: none; border: none; color: #fff; cursor: pointer; font-size: 22px; line-height: 1; opacity: .85; }
.sai-head .sai-close:hover { opacity: 1; }
.sai-head .sai-back { margin-left: 0; margin-right: 4px; font-size: 24px; }

.sai-body { flex: 1; overflow-y: auto; padding: 16px; background: #f6f8fb; }
.sai-msg { display: flex; margin-bottom: 12px; }
.sai-msg .sai-bubble {
  max-width: 82%; padding: 11px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; word-wrap: break-word;
}
.sai-msg.user { justify-content: flex-end; }
.sai-msg.user .sai-bubble { background: var(--sai-primary); color: #fff; border-bottom-right-radius: 4px; }
.sai-msg.bot .sai-bubble { background: #fff; color: var(--sai-dark); border: 1px solid #e3e9f1; border-bottom-left-radius: 4px; }
.sai-msg.bot .sai-bubble.has-table { max-width: 97%; }
.sai-msg.bot .sai-bubble a { color: var(--sai-primary); font-weight: 600; }
.sai-bubble p { margin: 0 0 8px; } .sai-bubble p:last-child { margin: 0; }
.sai-bubble ul { margin: 6px 0; padding-left: 18px; } .sai-bubble li { margin: 3px 0; }
.sai-bubble h4.sai-h { font-size: 15px; font-weight: 700; color: var(--sai-dark); margin: 12px 0 6px; line-height: 1.3; }
.sai-bubble h5.sai-h { font-size: 13.5px; font-weight: 700; color: var(--sai-primary); margin: 10px 0 5px; line-height: 1.3; text-transform: none; letter-spacing: 0; }
.sai-bubble h4.sai-h:first-child, .sai-bubble h5.sai-h:first-child { margin-top: 0; }
.sai-bubble strong { font-weight: 700; color: var(--sai-dark); }

/* Markdown tables (e.g. product spec answers) */
.sai-bubble .sai-tablewrap {
  margin: 10px 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid #dbe3ee; border-radius: 8px;
}
.sai-bubble table.sai-md-table {
  border-collapse: collapse; width: 100%; font-size: 12px; background: #fff;
}
.sai-bubble table.sai-md-table th {
  background: var(--sai-primary); color: #fff; font-weight: 700;
  text-align: left; padding: 7px 9px; white-space: nowrap; border-right: 1px solid rgba(255,255,255,.18);
}
.sai-bubble table.sai-md-table th:last-child { border-right: none; }
.sai-bubble table.sai-md-table td {
  padding: 6px 9px; border-top: 1px solid #eef1f5; border-right: 1px solid #eef1f5;
  color: var(--sai-dark); white-space: nowrap; vertical-align: top;
}
.sai-bubble table.sai-md-table td:last-child { border-right: none; }
.sai-bubble table.sai-md-table tbody tr:nth-child(even) { background: #f6f8fb; }
.sai-bubble table.sai-md-table tbody tr:hover { background: var(--sai-light); }

.sai-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.sai-typing span { width: 7px; height: 7px; background: var(--sai-accent); border-radius: 50%; animation: sai-bounce 1.2s infinite; }
.sai-typing span:nth-child(2){ animation-delay:.15s;} .sai-typing span:nth-child(3){ animation-delay:.3s;}
@keyframes sai-bounce { 0%,60%,100%{ transform: translateY(0); opacity:.5;} 30%{ transform: translateY(-5px); opacity:1;} }

.sai-quick { display: flex; flex-direction: column; gap: 6px; padding: 0 16px 8px; background: #f6f8fb; }
.sai-quick button {
  font-size: 12.5px; background: #fff; border: 1px solid #d5dee9; color: var(--sai-dark);
  padding: 9px 13px; border-radius: 12px; cursor: pointer; transition: all .12s;
  text-align: left; width: 100%; line-height: 1.35;
  white-space: normal; overflow-wrap: break-word; word-break: break-word; hyphens: auto;
  display: block;
}
.sai-quick button:hover,
.sai-quick button:focus {
  background: var(--sai-light);
  border-color: var(--sai-primary);
  color: var(--sai-dark);   /* keep text readable on hover */
}
.sai-quick button { height: auto !important; min-height: 0; max-width: 100%; text-overflow: clip; box-sizing: border-box; }
.sai-panel, .sai-panel * { box-sizing: border-box; }

.sai-foot { padding: 12px; border-top: 1px solid #e3e9f1; background: #fff; }
.sai-input-row { display: flex; gap: 8px; align-items: flex-end; }
.sai-input-row textarea {
  flex: 1; resize: none; border: 1px solid #d5dee9; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; max-height: 110px; line-height: 1.4;
  color: var(--sai-dark);
}
.sai-input-row textarea:focus { outline: none; border-color: var(--sai-primary); box-shadow: 0 0 0 3px rgba(28,91,184,.12); }
.sai-send {
  background: var(--sai-primary); border: none; color: #fff; width: 42px; height: 42px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sai-send:hover { background: var(--sai-dark); }
.sai-send:disabled { opacity: .5; cursor: default; }
.sai-send svg { width: 20px; height: 20px; }
.sai-disclaimer { text-align: center; font-size: 11px; color: var(--sai-accent); margin: 8px 0 0; }

/* Inline embed via shortcode */
.schnorr-ai-inline .sai-panel {
  position: relative; inset: auto; width: 100%; max-width: 100%; height: 560px; display: flex; box-shadow: 0 8px 30px rgba(20,40,70,.12);
}
.schnorr-ai-inline .sai-launch { display: none; }

/* Full-page assistant (dedicated mobile page) */
.schnorr-ai-fullpage { margin: 0; padding: 0; }
.schnorr-ai-fullpage .sai-panel {
  height: 100vh;
  height: 100dvh;
  min-height: 420px;
  width: 100%;
  border-radius: 0; box-shadow: none; border: none;
  overflow: hidden;
}
.schnorr-ai-fullpage .sai-head { border-radius: 0; }

/* On phones: pin the whole chat to the visible viewport, breaking out of the
   theme's page container so nothing behind it can show through or shift. */
@media (max-width: 700px) {
  .schnorr-ai-fullpage {
    position: fixed; inset: 0; z-index: 2147483000;
    width: 100vw; height: 100vh; height: 100dvh;
    background: #fff;
  }
  .schnorr-ai-fullpage .sai-panel {
    position: fixed; inset: 0;
    width: 100vw; max-width: 100vw;
    height: 100vh; height: 100dvh;
    min-height: 0;
    display: flex; flex-direction: column;
  }
  .schnorr-ai-fullpage .sai-body { flex: 1 1 auto; min-height: 0; }
  .schnorr-ai-fullpage .sai-head,
  .schnorr-ai-fullpage .sai-quick,
  .schnorr-ai-fullpage .sai-foot { flex: 0 0 auto; }
}

/* Give the full-page chat a bit more breathing room on wider screens */
@media (min-width: 700px) {
  .schnorr-ai-fullpage .sai-panel { max-width: 760px; margin: 0 auto; height: 78vh; min-height: 560px; border-radius: 14px; box-shadow: 0 8px 30px rgba(20,40,70,.12); }
  .schnorr-ai-fullpage .sai-head { border-radius: 14px 14px 0 0; }
}

@media (max-width: 480px) {
  /* Comfortable bottom sheet. Height/offset are refined live by JS
     (VisualViewport) so the on-screen keyboard never breaks the layout. */
  .sai-panel {
    width: 100vw;
    height: 80vh;                /* JS overrides with an exact px height */
    max-height: none;
    bottom: 0; right: 0 !important; left: 0 !important;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 40px rgba(20,40,70,.28);
  }
  .sai-panel.open { animation: sai-sheet-in .22s ease; }
  @keyframes sai-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* Grab handle */
  .sai-panel::before {
    content: ""; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.55); z-index: 2;
  }
  .sai-head { padding-top: 18px; gap: 8px; padding-left: 12px; padding-right: 12px; }
  /* Full-page is a real page, not a bottom sheet: no grab handle, no slide-up, no extra top padding. */
  .schnorr-ai-fullpage .sai-panel::before { display: none; }
  .schnorr-ai-fullpage .sai-panel.open { animation: none; }
  .schnorr-ai-fullpage .sai-head { padding-top: 14px; }
  .sai-head img { height: 22px; flex: 0 0 auto; }
  .sai-head .sai-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .sai-head > div { min-width: 0; overflow: hidden; }   /* title wrapper can shrink */

  .sai-launch { padding: 13px 16px; bottom: 18px; }
  .sai-launch .sai-launch-label { display: inline; }
  #schnorr-ai-root[data-pos="right"] .sai-launch { right: 16px; }
  #schnorr-ai-root[data-pos="left"]  .sai-launch { left: 16px; }

  .sai-head .sai-newchat { padding: 5px 10px; font-size: 11.5px; flex: 0 0 auto; }
  .sai-head .sai-close { flex: 0 0 auto; }
  .sai-body { padding: 14px; -webkit-overflow-scrolling: touch; }
  .sai-msg .sai-bubble { max-width: 86%; font-size: 14px; }
  .sai-quick { padding: 0 14px 8px; }
  .sai-quick button { font-size: 12px; }
  .sai-foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
}
