/* ===== Never block LMS scrolling / clicks ===== */
.pa-root {
  pointer-events: none !important;
  width: auto !important;
  height: auto !important;
  max-width: 160px;
  max-height: 180px;
}
.pa-root.pa-open {
  max-width: none;
  max-height: none;
  pointer-events: none !important;
}
.pa-root .pa-launcher { pointer-events: auto !important; }
.pa-root.pa-open .pa-panel { pointer-events: auto !important; }
/* Confetti / tips must never capture input */
.pa-confetti, .pa-tip, .pa-greet, .pa-name { pointer-events: none !important; }

/* ---- Hide PIMSU on LMS login / auth screens ---- */
body[data-view="login"] .pa-root,
body[data-view="auth"] .pa-root,
.pims-login ~ .pa-root,
body:has(.pims-login) .pa-root,
html:has(.pims-login) .pa-root {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  z-index: -1 !important;
}

/* ============================================================
   PIMSU — Paragon Institute of Modern Studies assistant
   Midnight navy · Paragon gold · pearl
   ============================================================ */
.pa-root {
  --pa-navy: #0B1226;
  --pa-indigo: #1A2456;
  --pa-indigo-2: #2A3585;
  --pa-gold: #F6B73C;
  --pa-gold-deep: #C9921E;
  --pa-gold-ink: #8A5A00;          /* gold that is readable as text on ivory */
  --pa-pearl: #FFF9EC;
  --pa-ivory: #FBF7F0;
  --pa-ink: #0A0F1F;
  --pa-mute: #6B7392;
  --pa-line: rgba(11, 18, 38, .08);

  position: fixed; z-index: 40;
  right: 16px; left: auto;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  pointer-events: none;
}
.pa-root * { box-sizing: border-box; }
.pa-root .pa-launcher,
.pa-root.pa-open .pa-panel,
.pa-root.pa-open .pa-panel * { pointer-events: auto; }

.pa-root button:focus-visible,
.pa-root a:focus-visible,
.pa-root textarea:focus-visible {
  outline: 2px solid var(--pa-gold);
  outline-offset: 2px;
}

/* ---- Launcher (base — robot styling lives in pimsu-robot.css) ---- */
.pa-launcher {
  border: 0; cursor: pointer; position: relative;
  display: grid; place-items: center; color: var(--pa-navy);
  transition: transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.pa-launcher:active { transform: scale(.94); }
.pa-launcher svg.pa-i-chat,
.pa-launcher svg.pa-i-close { display: none !important; }

.pa-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: #B42318; color: #fff; font-size: .7rem; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--pa-ivory);
}
.pa-badge.show { display: flex; }
.pa-launcher.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(246, 183, 60, .7); animation: pa-pulse 2s ease-out infinite;
}
@keyframes pa-pulse { 0% { transform: scale(1); opacity: .9 } 100% { transform: scale(1.6); opacity: 0 } }

/* ---- Panel ---- */
.pa-panel {
  position: absolute; right: 0; left: auto; bottom: 168px;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 236px));
  background: var(--pa-ivory);
  border-radius: 28px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow:
    0 40px 80px -24px rgba(11, 18, 38, .45),
    0 12px 28px -10px rgba(11, 18, 38, .2),
    0 0 0 1px rgba(11, 18, 38, .06);
  opacity: 0; transform: translateY(24px) scale(.95); transform-origin: 90% 100%;
  pointer-events: none;
  transition: opacity .25s ease, transform .38s cubic-bezier(.34, 1.4, .64, 1);
}
.pa-root.pa-open { z-index: 10050 !important; }
.pa-root.pa-open .pa-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ---- Header ---- */
.pa-head {
  padding: 16px 16px 18px; display: flex; align-items: center; gap: 12px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(246, 183, 60, .32) 0%, transparent 55%),
    radial-gradient(90% 120% at 0% 100%, rgba(91, 63, 176, .35) 0%, transparent 60%),
    linear-gradient(135deg, var(--pa-navy) 0%, var(--pa-indigo) 62%, var(--pa-indigo-2) 100%);
  color: #fff; position: relative; overflow: hidden; flex: none;
}
.pa-head::after {            /* gold hairline */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--pa-gold) 30%, #FFE29A 50%, var(--pa-gold) 70%, transparent);
  opacity: .9; pointer-events: none;
}
.pa-head .pa-title { flex: 1; min-width: 0; }
.pa-head .pa-title b {
  display: block; font-family: 'Fraunces', Georgia, serif; font-weight: 700;
  font-size: 1.28rem; line-height: 1.1; letter-spacing: .01em;
}
.pa-head .pa-title small { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.pa-head .pa-school-name {
  font-size: .74rem; font-weight: 500; line-height: 1.25; color: rgba(255, 255, 255, .86);
}
.pa-head .pa-status {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content;
  font-size: .68rem; font-weight: 600; color: #A7F3C4;
  background: rgba(34, 197, 94, .14); border: 1px solid rgba(134, 239, 172, .25);
  padding: 2px 8px 2px 7px; border-radius: 999px;
}
.pa-head .pa-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: #22C55E;
  box-shadow: 0 0 8px #22C55E; animation: pa-blink 2s ease-in-out infinite;
}
@keyframes pa-blink { 0%, 100% { opacity: 1 } 50% { opacity: .4 } }
.pa-head .pa-close {
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16);
  width: 34px; height: 34px; border-radius: 12px; color: #fff; cursor: pointer;
  display: grid; place-items: center; transition: background .2s ease; flex: none;
}
.pa-head .pa-close:hover { background: rgba(255, 255, 255, .22); }
.pa-head .pa-close svg { width: 16px; height: 16px; }

/* ---- Messages ---- */
.pa-body {
  flex: 1; overflow-y: auto; padding: 18px 14px 12px; display: flex; flex-direction: column; gap: 14px;
  background-color: var(--pa-ivory);
  /* the Paragon diamond, barely there */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cpath d='M22 15l7 7-7 7-7-7z' fill='none' stroke='%230B1226' stroke-opacity='.045' stroke-width='1'/%3E%3C/svg%3E");
  overscroll-behavior: contain;
}
.pa-body::-webkit-scrollbar { width: 6px; }
.pa-body::-webkit-scrollbar-thumb { background: rgba(11, 18, 38, .16); border-radius: 6px; }

.pa-msg { display: flex; gap: 9px; align-items: flex-start; max-width: 100%; animation: pa-in .32s cubic-bezier(.2, .8, .3, 1); }
@keyframes pa-in { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }
.pa-msg.pa-user { flex-direction: row-reverse; }
.pa-msg .pa-col { min-width: 0; max-width: calc(100% - 46px); display: flex; flex-direction: column; }
.pa-msg.pa-user .pa-col { align-items: flex-end; }

.pa-msg .pa-bubble {
  padding: 11px 15px; font-size: .94rem; line-height: 1.52;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; width: fit-content; max-width: 100%;
}
.pa-msg.pa-bot .pa-bubble {
  background: #fff; color: var(--pa-ink);
  border-radius: 20px 20px 20px 6px;
  box-shadow: 0 1px 0 rgba(11, 18, 38, .04), 0 8px 20px -10px rgba(11, 18, 38, .22), 0 0 0 1px var(--pa-line);
}
.pa-msg.pa-user .pa-bubble {
  background: linear-gradient(135deg, var(--pa-indigo-2) 0%, var(--pa-indigo) 55%, var(--pa-navy) 100%);
  color: #fff; border-radius: 20px 20px 6px 20px;
  box-shadow: 0 10px 22px -10px rgba(11, 18, 38, .6);
}
.pa-bubble strong { font-weight: 700; }
.pa-msg.pa-bot .pa-bubble a { color: var(--pa-indigo-2); font-weight: 600; text-decoration-color: rgba(42, 53, 133, .35); text-underline-offset: 2px; }
.pa-msg.pa-bot .pa-bubble a:hover { text-decoration-color: currentColor; }

.pa-msg .pa-mini-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center;
  color: var(--pa-navy);
}
.pa-msg .pa-mini-avatar svg { width: 18px; height: 18px; }
.pa-msg.pa-user .pa-mini-avatar { background: linear-gradient(135deg, #5B3FB0, #B06B8E); color: #fff; }

/* --- Typing --- */
.pa-bubble.pa-bubble-typing { padding: 0; }
.pa-typing { display: flex; gap: 5px; padding: 15px 17px; }
.pa-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--pa-gold-deep); animation: pa-dot 1.2s ease-in-out infinite; }
.pa-typing span:nth-child(2) { animation-delay: .15s; }
.pa-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pa-dot { 0%, 80%, 100% { transform: translateY(0); opacity: .35 } 40% { transform: translateY(-5px); opacity: 1 } }

/* --- Step-by-step guide --- */
.pa-steps {
  margin-top: 8px; padding: 12px 14px 12px 14px; border-radius: 16px; background: #fff;
  box-shadow: 0 0 0 1px var(--pa-line), 0 8px 18px -12px rgba(11, 18, 38, .3);
  border-left: 3px solid var(--pa-gold);
}
.pa-steps-title { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: .86rem; color: var(--pa-navy); margin-bottom: 8px; }
.pa-steps ol { list-style: none; counter-reset: pa-step; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pa-steps li { counter-increment: pa-step; position: relative; padding-left: 28px; font-size: .86rem; line-height: 1.45; color: #1d2540; }
.pa-steps li::before {
  content: counter(pa-step); position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: .72rem; font-weight: 800; color: var(--pa-navy);
  background: linear-gradient(135deg, #FFE29A, var(--pa-gold));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

/* --- Action buttons (first one is the main action) --- */
.pa-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.pa-actions a {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px;
  font-size: .82rem; font-weight: 700; text-decoration: none; cursor: pointer;
  background: #fff; color: var(--pa-navy); box-shadow: 0 0 0 1px rgba(11, 18, 38, .12);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.pa-actions a:hover { transform: translateY(-1px); box-shadow: 0 0 0 1.5px var(--pa-gold), 0 8px 16px -8px rgba(246, 183, 60, .7); }
.pa-actions a:first-child {
  background: linear-gradient(135deg, var(--pa-indigo-2), var(--pa-navy)); color: #fff; box-shadow: 0 10px 18px -10px rgba(11, 18, 38, .7);
}
.pa-actions a:first-child:hover { box-shadow: 0 0 0 1.5px var(--pa-gold), 0 12px 20px -10px rgba(11, 18, 38, .8); }
.pa-actions a:first-child svg { color: var(--pa-gold); }
.pa-actions svg { width: 14px; height: 14px; flex: none; }

/* --- Follow-up chips --- */
.pa-followups { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 0; padding-left: 43px; animation: pa-in .35s ease; }
.pa-followups button {
  padding: 7px 12px; border-radius: 999px; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer;
  background: rgba(246, 183, 60, .12); color: var(--pa-gold-ink); border: 1px solid rgba(201, 146, 30, .4);
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
}
.pa-followups button:hover { background: rgba(246, 183, 60, .26); border-color: var(--pa-gold-deep); transform: translateY(-1px); }

/* ---- Welcome ---- */
.pa-welcome { padding: 14px 8px 6px; text-align: center; color: var(--pa-mute); animation: pa-in .4s ease; }
.pa-welcome .pa-welcome-icon {
  width: 84px; height: 84px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff 0%, rgba(255, 233, 176, .75) 52%, rgba(246, 183, 60, .0) 72%);
}
.pa-welcome .pa-welcome-bot { display: block; width: 68px; height: 68px; filter: drop-shadow(0 8px 12px rgba(11, 18, 38, .22)); }
.pa-welcome .pa-welcome-bot svg { width: 100%; height: 100%; display: block; }
.pa-welcome h3 { font-family: 'Fraunces', Georgia, serif; font-size: 1.3rem; color: var(--pa-navy); margin: 0 0 2px; font-weight: 700; }
.pa-welcome .pa-welcome-school { font-family: 'Fraunces', Georgia, serif; font-size: .92rem; font-style: italic; color: var(--pa-gold-ink); margin: 0 0 10px; }
.pa-welcome p { font-size: .88rem; line-height: 1.5; margin: 0 auto 16px; max-width: 300px; }
.pa-welcome .pa-welcome-school { max-width: none; margin-bottom: 10px; }
.pa-quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.pa-quick button {
  padding: 9px 14px; border-radius: 999px; border: 0; background: #fff; color: var(--pa-ink);
  font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 0 0 1px var(--pa-line), 0 6px 14px -8px rgba(11, 18, 38, .3);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.pa-quick button:hover { background: #FFFBEE; transform: translateY(-2px); box-shadow: 0 0 0 1.5px var(--pa-gold), 0 10px 18px -8px rgba(246, 183, 60, .7); }

/* ---- Input ---- */
.pa-foot { padding: 10px 12px 12px; background: #fff; border-top: 1px solid var(--pa-line); flex: none; }
.pa-input-row {
  display: flex; align-items: flex-end; gap: 8px; background: var(--pa-ivory); border-radius: 20px; padding: 6px 6px 6px 16px;
  box-shadow: inset 0 0 0 1.5px var(--pa-line); transition: box-shadow .2s ease;
}
.pa-input-row:focus-within { box-shadow: inset 0 0 0 1.5px var(--pa-navy), 0 0 0 4px rgba(246, 183, 60, .22); }
.pa-input-row textarea {
  flex: 1; border: 0; outline: 0; background: transparent; resize: none;
  font-family: inherit; font-size: 16px; line-height: 1.4; color: var(--pa-ink);
  max-height: 110px; padding: 8px 0; min-height: 24px;
}
.pa-input-row textarea:focus-visible { outline: 0; }
.pa-input-row textarea::placeholder { color: #98A0BC; }
.pa-send {
  width: 40px; height: 40px; border-radius: 14px; border: 0; cursor: pointer; flex: none;
  background: linear-gradient(135deg, #FFE29A, var(--pa-gold) 55%, var(--pa-gold-deep)); color: var(--pa-navy); display: grid; place-items: center;
  box-shadow: 0 8px 16px -8px rgba(201, 146, 30, .9), inset 0 1px 0 rgba(255, 255, 255, .6);
  transition: transform .2s ease, box-shadow .3s ease;
}
.pa-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.pa-send:hover:not(:disabled) { transform: translateY(-1px) rotate(-6deg); box-shadow: 0 12px 22px -8px rgba(201, 146, 30, 1), inset 0 1px 0 rgba(255, 255, 255, .6); }
.pa-send svg { width: 17px; height: 17px; }
.pa-foot .pa-hint { font-size: .68rem; color: #8A92AE; text-align: center; margin-top: 7px; letter-spacing: .01em; }

/* ---- Day-mode tint (Living Sky aware) ---- */
html[data-tod="day"] .pa-body { background-color: #F7F1E6; }

/* ---- Mobile ---- */
@media (max-width: 520px) {
  .pa-root { right: 6px; left: auto; bottom: calc(102px + env(safe-area-inset-bottom, 0px)); }
  .pa-panel { width: calc(100vw - 12px); height: calc(100vh - 180px); bottom: 60px; right: 0; left: auto; border-radius: 24px; }
}
@media (min-width: 900px) {
  .pa-root { right: 20px; left: auto; bottom: 24px; }
  .pa-panel { right: 0; left: auto; bottom: 178px; }
}
/* LMS: robot must never steal dock/tab touches */
@media (max-width: 767px) {
  .pa-root {
    right: 8px; left: auto;
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    width: auto; height: auto;
    z-index: 850 !important;           /* below #pimsDock (900) while closed */
    pointer-events: none !important;
  }
  .pa-root.pa-open { z-index: 10050 !important; }
  .pa-panel { right: 0; left: auto; bottom: 64px; width: min(400px, calc(100vw - 16px)); height: min(540px, calc(100vh - 170px)); }
  .pa-root .pa-launcher,
  .pa-root.pa-open .pa-panel { pointer-events: auto !important; }
  .pa-head { padding: 14px; }
  .pa-head .pa-title b { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pa-msg, .pa-welcome, .pa-followups, .pa-panel { animation: none !important; transition-duration: .001ms !important; }
}
