/* Floating AI tutor — shared by the explorer and the exam workspace. */
.pe-ai-fab {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px 11px 13px;
  border: 1px solid rgba(239, 156, 44, 0.55);
  border-radius: 999px;
  background: linear-gradient(135deg, #ffc46b, #ef9c2c);
  color: #1b1206;
  font: 600 12px/1 inherit;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 10px 26px -10px rgba(239, 156, 44, 0.75), 0 2px 8px rgba(0, 0, 0, 0.28);
}
.pe-ai-fab:hover { filter: brightness(1.06); }
.pe-ai-fab svg { width: 16px; height: 16px; flex: none; }

@media (max-width: 720px) {
  .pe-ai-fab { bottom: calc(126px + env(safe-area-inset-bottom, 0px)); right: 14px; padding: 10px 12px; }
}
.pe-ai-fab span { font-weight: 700; letter-spacing: 0.08em; }

.pe-ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147482999;
  display: none;
  background: rgba(3, 8, 18, 0.62);
  backdrop-filter: blur(3px);
}

.pe-ai-panel {
  position: fixed;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%);
  z-index: 2147483001;
  width: min(440px, calc(100vw - 24px));
  height: 54vh;
  max-height: 580px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(110, 150, 220, 0.3);
  border-radius: 16px;
  background: #081226;
  color: #dfe8ff;
  box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.85);
}
@media (max-width: 720px) {
  .pe-ai-panel {
    left: 0;
    right: 0;
    bottom: 0;
    transform: none;
    width: 100%;
    height: 54vh;
    max-height: none;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

.pe-ai-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid rgba(110, 150, 220, 0.18);
  background: linear-gradient(180deg, rgba(77, 141, 255, 0.14), rgba(77, 141, 255, 0));
}
.pe-ai-head b { font: 600 12.5px/1.2 inherit; letter-spacing: 0.04em; }
.pe-ai-head .pe-ai-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #ffc46b; box-shadow: 0 0 10px rgba(255, 196, 107, 0.9);
}
.pe-ai-close {
  margin-left: auto;
  width: 26px; height: 26px;
  border: 0; border-radius: 6px;
  background: transparent; color: #93a7cd;
  font: 400 16px/1 inherit; cursor: pointer;
}
.pe-ai-close:hover { background: rgba(110, 150, 220, 0.14); color: #fff; }

.pe-ai-context {
  margin: 0;
  padding: 7px 12px;
  font: 400 10.5px/1.5 ui-monospace, monospace;
  color: #93a7cd;
  border-bottom: 1px solid rgba(110, 150, 220, 0.12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pe-ai-log {
  flex: 1;
  min-height: 96px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pe-ai-log.is-gate { justify-content: center; }

.pe-ai-msg {
  max-width: 88%;
  padding: 8px 10px;
  border-radius: 9px;
  font: 400 11.5px/1.6 inherit;
  white-space: pre-wrap;
  word-break: break-word;
}
.pe-ai-msg.is-user {
  align-self: flex-end;
  background: rgba(77, 141, 255, 0.18);
  border: 1px solid rgba(77, 141, 255, 0.35);
}
.pe-ai-msg.is-ai {
  align-self: flex-start;
  background: rgba(110, 150, 220, 0.1);
  border: 1px solid rgba(110, 150, 220, 0.22);
}
.pe-ai-msg.is-note { align-self: center; color: #93a7cd; font-size: 10.5px; background: none; border: 0; }

.pe-ai-form {
  display: flex;
  gap: 8px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(110, 150, 220, 0.18);
  background: rgba(6, 12, 26, 0.9);
}
.pe-ai-input {
  flex: 1;
  min-height: 38px;
  max-height: 96px;
  resize: none;
  padding: 9px 10px;
  border: 1px solid rgba(110, 150, 220, 0.28);
  border-radius: 8px;
  background: #0a1224;
  color: #dfe8ff;
  font: 400 11.5px/1.5 inherit;
}
.pe-ai-input:focus { outline: none; border-color: #4d8dff; }
.pe-ai-send {
  flex: none;
  padding: 0 13px;
  border: 1px solid #ef9c2c;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffc46b, #ef9c2c);
  color: #1b1206;
  font: 600 11.5px/1 inherit;
  cursor: pointer;
}
.pe-ai-send:disabled { opacity: 0.6; cursor: default; }

.pe-ai-gate { padding: 16px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.pe-ai-gate .price {
  font: 600 24px/1 inherit;
  color: #ffc46b;
}
.pe-ai-gate h3 { margin: 0; font: 600 13px/1.4 inherit; color: #fff; }
.pe-ai-gate p { margin: 0; font: 400 11px/1.6 inherit; color: #93a7cd; }
.pe-ai-gate .pe-ai-gold {
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid #ef9c2c;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffc46b, #ef9c2c);
  color: #1b1206;
  font: 600 11.5px/1 inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.pe-ai-gate .pe-ai-plain {
  padding: 8px 12px;
  border: 1px solid rgba(110, 150, 220, 0.35);
  border-radius: 8px;
  background: transparent;
  color: #dfe8ff;
  font: 500 11px/1 inherit;
  cursor: pointer;
}
