.sbm-root {
  --sbm-accent: #d2ad63;
  --sbm-bg: #090a0d;
  --sbm-panel: rgba(15, 16, 20, .97);
  --sbm-text: #f7f4ec;
  --sbm-muted: #b8b4aa;
  --sbm-border: rgba(210, 173, 99, .28);
  position: relative;
  z-index: 999999;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sbm-launch {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  padding: 12px 16px 12px 12px;
  border: 1px solid var(--sbm-border);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(14,15,19,.98), rgba(32,27,19,.98));
  color: var(--sbm-text);
  box-shadow: 0 18px 50px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.03);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.sbm-launch:hover { transform: translateY(-2px); box-shadow: 0 22px 58px rgba(0,0,0,.42), 0 0 28px rgba(210,173,99,.12); }
.sbm-launch-orb,
.sbm-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #16110a;
  background: radial-gradient(circle at 30% 25%, #fff1bd 0, #e0bc70 34%, var(--sbm-accent) 66%, #8a642a 100%);
  box-shadow: 0 0 26px rgba(210,173,99,.28);
  font-weight: 900;
  letter-spacing: .04em;
}
.sbm-launch-copy { display: grid; text-align: left; }
.sbm-launch-copy strong { font-size: 14px; line-height: 1.2; }
.sbm-launch-copy small { margin-top: 3px; font-size: 11px; color: var(--sbm-muted); }

.sbm-panel {
  position: fixed;
  right: 22px;
  bottom: 92px;
  width: min(430px, calc(100vw - 28px));
  height: min(690px, calc(100vh - 125px));
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  overflow: hidden;
  border: 1px solid var(--sbm-border);
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 5%, rgba(210,173,99,.13), transparent 33%),
    linear-gradient(180deg, rgba(20,20,24,.985), rgba(8,9,12,.99));
  color: var(--sbm-text);
  box-shadow: 0 26px 90px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.02) inset;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.985);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s ease, visibility .22s ease;
}
.sbm-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.sbm-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sbm-kicker { display: block; margin-bottom: 5px; color: var(--sbm-accent); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.sbm-panel-head h2 { margin: 0; color: var(--sbm-text); font-size: 23px; line-height: 1.2; }
.sbm-close { border: 0; background: transparent; color: #d7d3ca; font-size: 30px; line-height: 1; cursor: pointer; }

.sbm-thread {
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}
.sbm-message { display: flex; align-items: flex-end; gap: 9px; margin: 0 0 14px; }
.sbm-message > div:last-child { min-width: 0; }
.sbm-user { justify-content: flex-end; }
.sbm-avatar { width: 31px; height: 31px; font-size: 10px; }
.sbm-bubble {
  max-width: 315px;
  padding: 12px 14px;
  border-radius: 17px 17px 17px 6px;
  background: rgba(255,255,255,.075);
  border: 1px solid rgba(255,255,255,.07);
  color: #f8f6ef;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sbm-user .sbm-bubble {
  border-radius: 17px 17px 6px 17px;
  color: #1b150d;
  background: linear-gradient(135deg, #f0d391, var(--sbm-accent));
  border-color: rgba(255,255,255,.14);
}
.sbm-sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0 0 2px; }
.sbm-sources span { padding: 5px 8px; border: 1px solid var(--sbm-border); border-radius: 999px; color: #d8c59a; background: rgba(210,173,99,.06); font-size: 10px; }

.sbm-prompts { display: flex; gap: 7px; overflow-x: auto; padding: 0 16px 12px; }
.sbm-prompts button {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid rgba(210,173,99,.22);
  border-radius: 999px;
  background: rgba(210,173,99,.06);
  color: #e8dfca;
  font-size: 11px;
  cursor: pointer;
}
.sbm-prompts button:hover { border-color: var(--sbm-accent); }

.sbm-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 13px 15px;
  border-top: 1px solid rgba(255,255,255,.07);
  background: rgba(5,6,8,.62);
}
.sbm-form textarea {
  min-height: 47px;
  max-height: 120px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 14px;
  outline: none;
  background: rgba(255,255,255,.055);
  color: #fff;
  font: inherit;
  font-size: 14px;
}
.sbm-form textarea:focus { border-color: var(--sbm-accent); box-shadow: 0 0 0 3px rgba(210,173,99,.09); }
.sbm-send {
  align-self: end;
  min-height: 47px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  color: #18120b;
  background: linear-gradient(135deg, #f2d99c, var(--sbm-accent));
  font-weight: 850;
  cursor: pointer;
}
.sbm-send:disabled { opacity: .5; cursor: wait; }
.sbm-footnote { margin: 0; padding: 0 18px 15px; color: #8e8a82; font-size: 9.5px; line-height: 1.45; background: rgba(5,6,8,.62); }

.sbm-typing { display: inline-flex; gap: 4px; align-items: center; min-width: 54px; }
.sbm-typing i { width: 6px; height: 6px; border-radius: 50%; background: #c9c4b9; animation: sbm-bounce 1.1s infinite ease-in-out; }
.sbm-typing i:nth-child(2) { animation-delay: .14s; }
.sbm-typing i:nth-child(3) { animation-delay: .28s; }
@keyframes sbm-bounce { 0%, 70%, 100% { transform: translateY(0); opacity: .4; } 35% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 600px) {
  .sbm-launch { right: 12px; bottom: 12px; min-width: 0; padding-right: 12px; }
  .sbm-launch-copy small { display: none; }
  .sbm-panel { right: 8px; bottom: 76px; width: calc(100vw - 16px); height: min(720px, calc(100vh - 88px)); border-radius: 20px; }
  .sbm-bubble { max-width: min(76vw, 315px); }
}

/* Admin */
.sbm-admin-wrap { max-width: 1250px; }
.sbm-admin-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 22px; align-items: start; margin-top: 20px; }
.sbm-admin-card { padding: 24px; border: 1px solid #dcdcde; border-radius: 12px; background: #fff; box-shadow: 0 5px 24px rgba(0,0,0,.04); }
.sbm-admin-card h2:first-child { margin-top: 0; }
.sbm-button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sbm-button-row form, .sbm-button-row p { margin: 0; }
@media (max-width: 980px) { .sbm-admin-grid { grid-template-columns: 1fr; } }

/* v1.0.1 theme-compatibility safeguards */
.sbm-root .sbm-launch {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 2147483000 !important;
}
.sbm-root .sbm-panel {
  z-index: 2147483001 !important;
}


/* v2.3 Conversation Intelligence */
.sbm-quick-replies { display:flex; gap:10px; flex-wrap:wrap; padding:2px 18px 12px 54px; }
.sbm-quick-replies button { min-width:86px; border:1px solid rgba(210,173,99,.72); border-radius:999px; padding:10px 18px; background:rgba(210,173,99,.10); color:#f3dfad; font:inherit; font-weight:800; cursor:pointer; }
.sbm-quick-replies button:hover, .sbm-quick-replies button:focus { background:linear-gradient(135deg,#f2d99c,var(--sbm-accent)); color:#18120b; outline:none; }

/* v2.6 Mobile Conversation + Youth Support */
@media (max-width: 600px) {
  .sbm-panel {
    top: 8px;
    right: 8px;
    bottom: auto;
    width: calc(100vw - 16px);
    height: calc(var(--sbm-vvh, 100dvh) - 16px);
    max-height: none;
    grid-template-rows: auto minmax(0,1fr) auto auto auto;
    border-radius: 18px;
  }
  .sbm-panel-head { padding: 13px 15px 11px; align-items:center; }
  .sbm-kicker { margin-bottom:2px; font-size:8px; letter-spacing:.13em; }
  .sbm-panel-head h2 { font-size:18px; }
  .sbm-close { font-size:26px; padding:3px 5px; }
  .sbm-thread { padding: 12px 10px 8px; overscroll-behavior:contain; }
  .sbm-message { gap:7px; margin-bottom:10px; }
  .sbm-avatar { width:26px; height:26px; font-size:9px; }
  .sbm-bubble { max-width:84vw; padding:10px 11px; font-size:15px; line-height:1.42; border-radius:15px 15px 15px 5px; }
  .sbm-user .sbm-bubble { border-radius:15px 15px 5px 15px; }
  .sbm-prompts { padding:0 10px 8px; gap:6px; }
  .sbm-prompts button { padding:7px 9px; font-size:10px; }
  .sbm-form { gap:7px; padding:8px 9px calc(8px + env(safe-area-inset-bottom)); }
  .sbm-form textarea { min-height:42px; height:42px; max-height:96px; resize:none; padding:10px 11px; font-size:16px; line-height:1.3; }
  .sbm-send { min-height:42px; padding:0 13px; border-radius:12px; font-size:15px; }
  .sbm-footnote { padding:0 11px 8px; font-size:8px; line-height:1.3; }
  .sbm-quick-replies { gap:7px; padding:2px 10px 9px 33px; }
  .sbm-quick-replies button { min-width:70px; padding:8px 12px; font-size:12px; }
  .sbm-chat-active .sbm-kicker { display:none; }
  .sbm-chat-active .sbm-panel-head { padding-top:9px; padding-bottom:9px; }
  .sbm-chat-active .sbm-prompts { display:none; }
  .sbm-chat-active .sbm-footnote { display:none; }
  .sbm-chat-active { grid-template-rows:auto minmax(0,1fr) auto; }
  .sbm-launch { display:none !important; }
}
