/* RAI footer dock — centered launcher + freely draggable pane */

#access.main-menu-buttons {
  display: flex;
  width: 100%;
  padding: 0 2px;
  margin: 0;
  box-sizing: border-box;
}

#access.main-menu-buttons > li {
  float: none;
  flex: 0 0 20%;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#access.main-menu-buttons > li > a,
#access.main-menu-buttons > li > button {
  box-sizing: border-box;
  padding-left: 0;
  padding-right: 0;
}

#open-rai-footer .rai-footer-icon {
  display: inline-block;
  width: 32px;
  height: 32px;
  vertical-align: middle;
  background: url(/img/runcible-spork-logo.png) center / contain no-repeat;
  opacity: 0.85;
}

/* Thin footer strip under content column (not over left menu) */
.rai-footer {
  position: fixed;
  left: 280px;
  right: 0;
  bottom: 0;
  height: 38px;
  z-index: 10042;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  box-sizing: border-box;
  background: #f7f2ea;
  border-top: 1px solid #ddd4c8;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.04);
  pointer-events: auto;
}

#open-rai-footer {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 2px 4px;
  margin: 0;
  cursor: pointer;
  line-height: 1;
  border-radius: 6px;
}

#open-rai-footer:hover,
#open-rai-footer.is-active {
  background: rgba(47, 74, 58, 0.08);
}

#open-rai-footer .rai-footer-icon {
  width: 28px;
  height: 28px;
}

/* Docked pane above footer strip */
.rai-panel {
  position: fixed;
  bottom: 38px;
  width: min(520px, calc(100vw - 300px));
  height: min(42vh, 480px);
  z-index: 10045;
  display: flex;
  flex-direction: column;
  background: #fffcf7;
  border: 1px solid #ddd4c8;
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.14);
  transform: translateY(calc(100% + 38px));
  transition: transform 0.22s ease;
  pointer-events: none;
  /* JS restores the saved offset; centered before JS initializes. */
  left: calc(280px + (100vw - 280px - min(520px, calc(100vw - 300px))) / 2);
  right: auto;
}

.rai-panel.is-open {
  transform: translateY(0);
  pointer-events: auto;
}

.rai-panel.is-dragging {
  transition: none;
  user-select: none;
}

.rai-dock-grip {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 6px;
  border-radius: 3px;
  background: #d0c6b8;
  cursor: grab;
  touch-action: none;
  z-index: 1;
}

.rai-dock-grip:active {
  cursor: grabbing;
}

.rai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid #ddd4c8;
  background: rgba(255, 252, 247, 0.96);
  flex-shrink: 0;
}

.rai-panel-header .title {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
}

.rai-panel-header .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.rai-panel-header button,
.rai-panel-header a {
  appearance: none;
  border: 0;
  background: transparent;
  color: #555;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  text-decoration: none;
}

.rai-panel-header #rai_new_chat {
  border: 1px solid #d0c6b8;
  border-radius: 6px;
  background: #fff;
}

.rai-focus-line {
  padding: 6px 14px;
  font-size: 12px;
  color: #666;
  border-bottom: 1px solid #eee6dc;
  background: #faf6f0;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rai-bubble {
  max-width: 92%;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.rai-bubble.user {
  align-self: flex-end;
  background: #e8f1f8;
  border: 1px solid #c9dceb;
}

.rai-bubble.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5ddd2;
}

.rai-bubble .rai-mode {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
  margin-bottom: 4px;
}

.rai-confirm-bar {
  padding: 8px 14px;
  border-top: 1px solid #eee6dc;
  background: #fff8ee;
  display: none;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.rai-confirm-bar.is-visible {
  display: flex;
}

.rai-confirm-bar button {
  appearance: none;
  border: 1px solid #c4b8a8;
  background: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.rai-confirm-bar button.primary {
  background: #2f4a3a;
  border-color: #2f4a3a;
  color: #fff;
}

.rai-compose {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #ddd4c8;
  background: #fffcf7;
  flex-shrink: 0;
}

.rai-compose textarea {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
  resize: vertical;
  border: 1px solid #d8d0c4;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  background: #fff;
}

.rai-compose button {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: #2f4a3a;
  color: #fff;
  padding: 0 14px;
  font-size: 13px;
  cursor: pointer;
  align-self: flex-end;
  height: 40px;
}

.rai-compose button:disabled {
  opacity: 0.5;
  cursor: default;
}

.mp-panel-rai {
  cursor: pointer;
  opacity: 0.75;
  margin-right: 2px;
  font-size: 14px;
  line-height: 1;
  vertical-align: middle;
}

.mp-panel-rai:hover,
.mp-panel-rai:focus {
  opacity: 1;
}

/* Leave room for footer strip in content column */
body.rai-footer-ready #page-content-wrapper,
body.rai-footer-ready .page-content-wrapper {
  padding-bottom: 38px;
}

@media (max-width: 900px) {
  .rai-footer {
    left: 0;
  }

  .rai-panel {
    width: min(520px, calc(100vw - 16px));
    left: calc((100vw - min(520px, calc(100vw - 16px))) / 2);
  }
}

@media (max-width: 640px) {
  .rai-panel {
    left: 0 !important;
    right: 0 !important;
    width: 100vw;
    height: 50vh;
    border-radius: 12px 12px 0 0;
  }

  .rai-dock-grip {
    display: none;
  }
}
