.forum-widget {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 20500;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
  max-width: min(420px, 92vw);
}

.forum-widget-toggle {
  display: none;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--bs-border-color) 70%, transparent);
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: 0 18px 38px rgba(15,23,42,.22);
  font-weight: 700;
  letter-spacing: .01em;
}

.forum-widget-panel {
  width: min(360px, 92vw);
  max-height: min(520px, 74vh);
  border-radius: 1.2rem;
  overflow: hidden;
  background: var(--bs-body-bg);
  border: 1px solid color-mix(in srgb, var(--bs-border-color) 70%, transparent);
  box-shadow: 0 28px 56px rgba(15,23,42,.35);
  display: flex;
  flex-direction: column;
  transform-origin: bottom left;
  transform: scale(.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease, visibility .18s ease;
}

.forum-widget-panel[hidden] {
  display: none !important;
}

.forum-widget.open .forum-widget-panel {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.forum-widget-header {
  padding: .85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  background: linear-gradient(135deg, rgba(13,110,253,.16), rgba(111,66,193,.16));
  border-bottom: 1px solid color-mix(in srgb, var(--bs-border-color) 80%, transparent);
}

.forum-widget-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-size: .75rem;
}

.forum-widget-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.forum-widget-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  background: #e5ddd5;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23e5ddd5"/><path d="M0 0L50 50L0 100" fill="rgba(255,255,255,0.05)"/></svg>');
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

html[data-bs-theme='dark'] .forum-widget-messages {
  background: #0a141f;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%230a141f"/><path d="M0 0L50 50L0 100" fill="rgba(255,255,255,0.02)"/></svg>');
}

.forum-widget-msg {
  display: flex;
  align-items: flex-end;
  max-width: 100%;
}

.forum-widget-msg.me { justify-content: flex-end; }
.forum-widget-msg.other { justify-content: flex-start; }

.forum-widget-bubble {
  max-width: 78%;
  padding: .55rem .75rem;
  border-radius: .9rem;
  line-height: 1.35;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  word-break: break-word;
}

.forum-widget-msg.me .forum-widget-bubble {
  background: #dcf8c6;
  color: #111b21;
  border-bottom-right-radius: .3rem;
}

.forum-widget-msg.other .forum-widget-bubble {
  background: #fff;
  color: #111b21;
  border-bottom-left-radius: .3rem;
}

html[data-bs-theme='dark'] .forum-widget-msg.me .forum-widget-bubble {
  background: #005c4b;
  color: #e9edef;
}

html[data-bs-theme='dark'] .forum-widget-msg.other .forum-widget-bubble {
  background: #1f2c34;
  color: #e9edef;
}

.forum-widget-meta {
  margin-top: .25rem;
  font-size: .7rem;
  opacity: .75;
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
}

.forum-widget-input {
  padding: .75rem;
  border-top: 1px solid color-mix(in srgb, var(--bs-border-color) 70%, transparent);
  background: color-mix(in srgb, var(--bs-body-bg) 85%, #fff);
  display: flex;
  gap: .5rem;
  align-items: center;
}

.forum-widget-input input {
  border-radius: 999px;
}

.forum-widget-login {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 1rem;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  text-align: center;
}

body.is-maintenance .forum-widget,
body.maintenance-widgets .forum-widget {
  display: none !important;
}

