/* ═══════════════════════════════════════════════════════════
   eScholar Chat — Brand-Matched UI v3.0
   Matches eSecondarySchool.com · Light Theme · Mobile-First
   Navy #1B3A6B · Pink #E91E8C · White · Clean Professional
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── DESIGN TOKENS ──────────────────────────────────────── */
:root {
  --navy:           #1B3A6B;
  --navy-dark:      #0F2448;
  --navy-light:     #2A4F8F;
  --navy-pale:      #EEF2F9;
  --pink:           #E91E8C;
  --pink-light:     #FCE4F3;
  --pink-dark:      #C0176F;
  --green:          #00A86B;
  --green-light:    #E6F7F1;
  --white:          #FFFFFF;
  --gray-50:        #F8FAFC;
  --gray-100:       #F1F5F9;
  --gray-200:       #E2E8F0;
  --gray-300:       #CBD5E1;
  --gray-400:       #94A3B8;
  --gray-500:       #64748B;
  --gray-700:       #334155;
  --gray-900:       #0F172A;
  --text-primary:   #1B2D4F;
  --text-secondary: #4A6080;
  --text-muted:     #94A3B8;

  --grad-navy:      linear-gradient(135deg, #1B3A6B 0%, #0F2448 100%);
  --grad-pink:      linear-gradient(135deg, #E91E8C, #C0176F);
  --grad-hero:      linear-gradient(160deg, #1B3A6B 0%, #2A4F8F 50%, #1B3A6B 100%);

  --shadow-xs:      0 1px 4px rgba(27,58,107,0.08);
  --shadow-sm:      0 2px 10px rgba(27,58,107,0.10);
  --shadow-md:      0 4px 24px rgba(27,58,107,0.14);
  --shadow-lg:      0 12px 48px rgba(27,58,107,0.18);
  --shadow-pink:    0 4px 16px rgba(233,30,140,0.25);
  --shadow-navy:    0 4px 16px rgba(27,58,107,0.3);

  --radius-xs:      6px;
  --radius-sm:      10px;
  --radius-md:      16px;
  --radius-lg:      20px;
  --radius-xl:      28px;

  --font:           'Plus Jakarta Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  --chat-width:     400px;
  --chat-height:    600px;
}

/* ── RESET ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── FLOATING LAUNCHER ──────────────────────────────────── */
#escholar-launcher {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 62px; height: 62px;
  background: linear-gradient(135deg, #0066FF 0%, #0044CC 60%, #1B3A6B 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(0,102,255,0.5), 0 2px 8px rgba(0,0,0,0.2);
  z-index: 999999;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s;
  animation: launcherPop 0.6s 0.2s cubic-bezier(0.34,1.56,0.64,1) both;
  padding: 0;
  overflow: visible;
}
#escholar-launcher::before {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 3px solid rgba(0,102,255,0.4);
  animation: launcherRing 2.2s ease-out infinite;
  pointer-events: none;
}
#escholar-launcher::after {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 2px solid rgba(0,102,255,0.18);
  animation: launcherRing 2.2s ease-out infinite 0.5s;
  pointer-events: none;
}
@keyframes launcherRing {
  0%   { transform: scale(0.92); opacity: 1; }
  80%  { transform: scale(1.18); opacity: 0; }
  100% { opacity: 0; }
}
@keyframes launcherPop {
  from { transform: scale(0) rotate(-180deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}
#escholar-launcher:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 10px 32px rgba(0,102,255,0.6), 0 4px 12px rgba(0,0,0,0.2);
}
#escholar-launcher svg.launcher-icon {
  width: 38px; height: 38px;
  position: relative; z-index: 1;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}
#escholar-launcher .badge {
  position: absolute; top: -2px; right: -2px;
  background: #FFD700;
  color: #1B3A6B; font-size: 8px; font-weight: 900;
  font-family: var(--font-mono);
  padding: 2px 5px; border-radius: 10px;
  box-shadow: 0 2px 8px rgba(255,215,0,0.6);
  border: 2px solid #fff;
  letter-spacing: 0.5px;
  z-index: 2;
}
/* ── TOOLTIP ────────────────────────────────────────────── */
#escholar-launcher .esc-launcher-tip {
  position: absolute;
  bottom: 72px; right: 0;
  background: #1B3A6B;
  color: #fff;
  font-size: 12px; font-weight: 600;
  font-family: var(--font);
  padding: 9px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(27,58,107,0.35);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 220px;
  white-space: normal;
  text-align: right;
  line-height: 1.45;
  z-index: 3;
}
#escholar-launcher .esc-launcher-tip::after {
  content: '';
  position: absolute;
  bottom: -6px; right: 22px;
  border: 6px solid transparent;
  border-top-color: #1B3A6B;
  border-bottom: none;
}
/* Show on hover */
#escholar-launcher:hover .esc-launcher-tip {
  opacity: 1;
  transform: translateY(0);
}
/* Auto-show class (added by JS for 1.5s on load) */
#escholar-launcher .esc-launcher-tip.esc-tip-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── CHAT WINDOW ────────────────────────────────────────── */
#escholar-window {
  position: fixed;
  bottom: 94px; right: 24px;
  width: var(--chat-width);
  height: var(--chat-height);
  min-width: 300px;  max-width: 700px;
  min-height: 420px; max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  overflow: hidden;
  font-family: var(--font);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.16,1,0.3,1);
  /* Enable user resize from top-left corner */
  resize: both;
}
#escholar-window.hidden {
  opacity: 0;
  transform: scale(0.9) translateY(16px);
  pointer-events: none;
}
/* Resize handle hint — bottom-right corner */
#escholar-window::after {
  content: '';
  position: absolute;
  bottom: 4px; right: 4px;
  width: 12px; height: 12px;
  background: linear-gradient(135deg, transparent 40%, var(--gray-300) 40%, var(--gray-300) 55%, transparent 55%,
              transparent 65%, var(--gray-300) 65%, var(--gray-300) 80%, transparent 80%);
  pointer-events: none;
  opacity: 0.7;
  z-index: 10;
}

/* ── HEADER ─────────────────────────────────────────────── */
.esc-header {
  background: var(--grad-navy);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
/* Decorative top accent line */
.esc-header::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--pink), #FF6BB5, var(--pink));
  background-size: 200% 100%;
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%,100% { background-position: 0% 0%; }
  50%      { background-position: 100% 0%; }
}
/* Subtle pattern overlay */
.esc-header::after {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.esc-avatar {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, #E91E8C, #C0176F);
  border: 2.5px solid rgba(255,255,255,0.4);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative; z-index: 1;
  box-shadow: 0 4px 12px rgba(233,30,140,0.4);
  overflow: hidden;
}
.esc-avatar svg {
  width: 26px; height: 26px;
}
.esc-header-info { flex: 1; position: relative; z-index: 1; }
.esc-name {
  font-size: 14px; font-weight: 700;
  color: #fff; letter-spacing: -0.1px;
}
.esc-status {
  font-size: 10.5px; color: rgba(255,255,255,0.65);
  display: flex; align-items: center; gap: 5px;
  margin-top: 2px; font-weight: 500;
}
.esc-dot {
  width: 6px; height: 6px;
  background: #4ADE80; border-radius: 50%;
  animation: dotPulse 2s ease-in-out infinite;
  box-shadow: 0 0 6px #4ADE80;
}
@keyframes dotPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(0.7); }
}
.esc-header-actions { display: flex; gap: 6px; position: relative; z-index: 1; }
.esc-close {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7); font-size: 14px;
  cursor: pointer; width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-family: var(--font);
}
.esc-close:hover {
  background: rgba(233,30,140,0.3);
  border-color: rgba(233,30,140,0.5);
  color: #fff;
}

/* ── MESSAGES AREA ──────────────────────────────────────── */
.esc-messages {
  flex: 1; overflow-y: auto;
  padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
  background: var(--gray-50);
  background-image: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(27,58,107,0.04), transparent);
}
.esc-messages::-webkit-scrollbar { width: 4px; }
.esc-messages::-webkit-scrollbar-track { background: transparent; }
.esc-messages::-webkit-scrollbar-thumb {
  background: var(--gray-300); border-radius: 4px;
}
.esc-messages::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── MESSAGE ROWS ───────────────────────────────────────── */
.esc-msg {
  display: flex; align-items: flex-end; gap: 8px;
  animation: msgIn 0.32s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.esc-msg.user {
  flex-direction: row-reverse;
  animation: msgInUser 0.28s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes msgInUser {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── AVATARS ────────────────────────────────────────────── */
.esc-msg-avatar {
  width: 30px; height: 30px;
  border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  overflow: hidden;
}
.esc-msg-avatar.bot {
  background: linear-gradient(135deg, #E91E8C, #C0176F);
  box-shadow: 0 2px 8px rgba(233,30,140,0.35);
  border: 1.5px solid rgba(233,30,140,0.2);
}
.esc-msg-avatar.bot svg {
  width: 18px; height: 18px;
}
.esc-msg-avatar.usr {
  background: var(--pink-light);
  border: 1.5px solid rgba(233,30,140,0.2);
  font-size: 11px;
}

/* ── BUBBLES ────────────────────────────────────────────── */
.esc-bubble {
  max-width: 78%;
  padding: 10px 13px;
  font-size: 13.5px; line-height: 1.65;
}
.esc-bubble.bot {
  background: var(--white);
  color: var(--text-primary);
  border: 1px solid var(--gray-200);
  border-radius: 14px 14px 14px 3px;
  box-shadow: var(--shadow-xs);
}
.esc-bubble.usr {
  background: var(--grad-navy);
  color: #fff;
  border-radius: 14px 14px 3px 14px;
  font-weight: 500;
  box-shadow: var(--shadow-navy);
}
.esc-bubble.bot a { color: var(--navy); font-weight: 600; }
.esc-bubble.bot strong { color: var(--navy-dark); font-weight: 700; }
.esc-bubble.bot em { color: var(--text-secondary); }
.esc-bubble.bot ul, .esc-bubble.bot ol { padding-left: 16px; margin: 6px 0; }
.esc-bubble.bot li { margin-bottom: 4px; color: var(--text-secondary); }
.esc-bubble.bot li::marker { color: var(--navy); }
.esc-bubble.bot code {
  background: var(--navy-pale); padding: 2px 6px;
  border-radius: 4px; font-family: var(--font-mono);
  font-size: 11.5px; color: var(--navy);
  border: 1px solid var(--gray-200);
}
.esc-bubble.bot h1,.esc-bubble.bot h2,.esc-bubble.bot h3 {
  color: var(--navy-dark); margin: 8px 0 5px; font-weight: 700;
}
.esc-bubble.bot p { margin-bottom: 5px; }
.esc-bubble.bot p:last-child { margin-bottom: 0; }
.esc-bubble.bot blockquote {
  border-left: 3px solid var(--navy);
  padding-left: 10px; margin: 6px 0;
  color: var(--text-secondary);
  background: var(--navy-pale); padding: 6px 10px;
  border-radius: 0 6px 6px 0;
}

/* Timestamp */
.esc-time {
  font-size: 9.5px; color: var(--text-muted);
  margin-top: 3px; font-family: var(--font-mono);
}
.esc-msg.user .esc-time { text-align: right; }

/* ── TYPING INDICATOR ───────────────────────────────────── */
.esc-typing-row {
  display: flex; align-items: flex-end; gap: 8px;
  animation: msgIn 0.3s ease both;
}
.esc-typing-bubble {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px 14px 14px 3px;
  padding: 11px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-xs);
}
.esc-dots { display: flex; gap: 4px; align-items: center; }
.esc-dots span {
  width: 6px; height: 6px;
  background: var(--navy); border-radius: 50%;
  animation: dotBounce 1.3s ease-in-out infinite; opacity: 0.5;
}
.esc-dots span:nth-child(2) { animation-delay: 0.18s; }
.esc-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dotBounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.5; }
  30%          { transform: translateY(-8px); opacity: 1; }
}
.esc-think-label {
  font-size: 11px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── QUICK CHIPS ────────────────────────────────────────── */
.esc-chips {
  padding: 8px 12px 10px;
  display: flex; flex-wrap: wrap; gap: 6px;
  background: var(--white);
  border-top: 1px solid var(--gray-100);
  flex-shrink: 0;
}
.esc-chip {
  background: var(--navy-pale);
  border: 1px solid rgba(27,58,107,0.15);
  color: var(--navy); font-size: 11.5px; font-weight: 600;
  padding: 5px 11px; border-radius: 20px; cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
  font-family: var(--font); white-space: nowrap;
}
.esc-chip:hover {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.esc-chip:active { transform: translateY(0) scale(0.97); }

/* ── INPUT AREA ─────────────────────────────────────────── */
.esc-input-area {
  padding: 10px 12px 14px;
  background: var(--white);
  border-top: 1px solid var(--gray-100);
  display: flex; gap: 8px; align-items: flex-end;
  flex-shrink: 0;
}
.esc-input-wrap {
  flex: 1;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  display: flex; align-items: flex-end;
  padding: 9px 12px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.esc-input-wrap:focus-within {
  border-color: var(--navy);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(27,58,107,0.08);
}
#esc-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font);
  font-size: 13.5px; resize: none;
  max-height: 90px; min-height: 20px; line-height: 1.5;
}
#esc-input::placeholder { color: var(--text-muted); }

.esc-send {
  width: 40px; height: 40px;
  background: var(--grad-navy);
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-navy);
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.esc-send:hover {
  background: var(--grad-pink);
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-pink);
}
.esc-send:active { transform: scale(0.95); }
.esc-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.esc-send svg { width: 17px; height: 17px; fill: white; }

/* ── QUIZ CARD ──────────────────────────────────────────── */
.esc-quiz-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 14px; margin-top: 6px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.esc-quiz-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--grad-navy);
}
.esc-quiz-card h4 {
  color: var(--navy); font-size: 13px;
  margin-bottom: 12px; font-weight: 700;
  padding-top: 4px;
}
.esc-quiz-q {
  font-size: 13px; color: var(--text-primary);
  margin-bottom: 8px; font-weight: 600; line-height: 1.5;
}
.esc-quiz-opt {
  display: block; width: 100%;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  color: var(--text-secondary); font-size: 12.5px;
  padding: 9px 12px; border-radius: var(--radius-xs);
  cursor: pointer; text-align: left; margin-bottom: 6px;
  font-family: var(--font);
  transition: all 0.18s ease;
}
.esc-quiz-opt:hover {
  background: var(--navy-pale);
  border-color: rgba(27,58,107,0.4);
  color: var(--navy);
  transform: translateX(4px);
}
.esc-quiz-opt.selected {
  background: var(--navy-pale);
  border-color: var(--navy);
  color: var(--navy); font-weight: 600;
}

/* ── DIAGRAM WRAPPER ────────────────────────────────────── */
.esc-diagram-wrap {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: msgIn 0.4s 0.1s cubic-bezier(0.16,1,0.3,1) both;
}
.esc-diagram-label {
  background: var(--navy-pale);
  border-bottom: 1px solid var(--gray-200);
  padding: 7px 12px;
  font-size: 10.5px; font-weight: 700;
  color: var(--navy); letter-spacing: 0.6px;
  font-family: var(--font-mono); text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}

/* ── FEEDBACK BUTTONS ───────────────────────────────────── */
.esc-feedback {
  display: flex; gap: 5px; margin-top: 4px;
}
.esc-thumb {
  background: transparent; border: 1px solid var(--gray-200);
  color: var(--text-muted); font-size: 12px;
  width: 24px; height: 24px; border-radius: var(--radius-xs);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.esc-thumb:hover { background: var(--gray-100); transform: scale(1.1); }
.esc-thumb.up.active { background: #DCFCE7; border-color: #16A34A; }
.esc-thumb.down.active { background: var(--pink-light); border-color: var(--pink); }

/* ── COPY BUTTON ────────────────────────────────────────── */
.esc-copy-btn {
  background: transparent; border: 1px solid var(--gray-200);
  color: var(--text-muted); font-size: 10px;
  padding: 3px 8px; border-radius: var(--radius-xs);
  cursor: pointer; font-family: var(--font);
  transition: all 0.2s; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
.esc-copy-btn:hover {
  background: var(--navy-pale); border-color: rgba(27,58,107,0.3);
  color: var(--navy);
}
.esc-copy-btn.copied { color: #16A34A; border-color: #16A34A; }

/* ── STANDALONE PAGE ────────────────────────────────────── */
.esc-standalone-page {
  min-height: 100vh;
  background: linear-gradient(160deg, #0F2448 0%, #1B3A6B 40%, #1B3A6B 60%, #0F2448 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 16px; font-family: var(--font);
  position: relative; overflow: hidden;
}
/* Grid pattern */
.esc-standalone-page::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
/* Glow orbs */
.esc-standalone-page::after {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(233,30,140,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 80% 80%, rgba(0,168,107,0.1) 0%, transparent 60%);
  pointer-events: none;
}

.esc-standalone-wrap {
  width: 100%; max-width: 660px;
  position: relative; z-index: 1;
  animation: wrapIn 0.6s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes wrapIn {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Brand bar */
.esc-brand-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding: 0 4px;
}
.esc-brand-logo img {
  height: 30px; object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}
.esc-brand-badge {
  background: rgba(233,30,140,0.2);
  border: 1px solid rgba(233,30,140,0.4);
  color: #FF6BB5;
  font-size: 10px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px;
  font-family: var(--font-mono); letter-spacing: 0.5px;
}

/* Hero */
.esc-hero {
  text-align: center; margin-bottom: 20px;
  animation: heroIn 0.7s 0.1s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes heroIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.esc-hero h1 {
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 800; color: #fff;
  letter-spacing: -0.5px; line-height: 1.2; margin-bottom: 8px;
}
.esc-hero h1 span { color: #FF6BB5; }
.esc-hero p {
  font-size: 13.5px; color: rgba(255,255,255,0.65);
  max-width: 400px; margin: 0 auto; line-height: 1.6;
}

/* Pills */
.esc-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center; margin-top: 12px;
}
.esc-pill {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.75); font-size: 11.5px;
  padding: 4px 12px; border-radius: 20px; font-weight: 500;
}

/* Embedded window */
.esc-standalone-wrap #escholar-window {
  position: relative; bottom: auto; right: auto;
  width: 100%;
  height: min(580px, calc(100vh - 280px));
  transform: none; opacity: 1; pointer-events: all;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.1);
  animation: windowIn 0.6s 0.2s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes windowIn {
  from { opacity: 0; transform: scale(0.97) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Footer */
.esc-footer-note {
  text-align: center; color: rgba(255,255,255,0.4);
  font-size: 10.5px; margin-top: 12px;
  font-family: var(--font-mono); letter-spacing: 0.3px;
}
.esc-footer-note a { color: rgba(255,255,255,0.65); text-decoration: none; }
.esc-footer-note a:hover { color: #FF6BB5; }

/* ── MOBILE FIRST ───────────────────────────────────────── */
@media (max-width: 500px) {
  :root { --chat-height: calc(100vh - 100px); }

  #escholar-launcher { bottom: 14px; right: 14px; width: 52px; height: 52px; }

  #escholar-window {
    width: calc(100vw - 16px);
    right: 8px; left: 8px;
    bottom: 76px;
    height: calc(100vh - 98px);
    border-radius: var(--radius-md);
  }

  .esc-bubble { max-width: 84%; font-size: 13px; padding: 9px 12px; }
  .esc-standalone-page { padding: 10px; justify-content: flex-start; padding-top: 16px; }
  .esc-hero { margin-bottom: 14px; }
  .esc-hero h1 { font-size: 20px; }
  .esc-hero p  { font-size: 12.5px; }
  .esc-standalone-wrap #escholar-window { height: calc(100vh - 240px); min-height: 380px; }
  .esc-chips { padding: 6px 10px 8px; }
  .esc-chip  { font-size: 11px; padding: 4px 9px; }
  .esc-header { padding: 11px 12px; }
  .esc-messages { padding: 12px 10px; gap: 8px; }
  .esc-input-area { padding: 8px 10px 12px; }
  .esc-pills { gap: 5px; }
  .esc-pill  { font-size: 11px; padding: 3px 9px; }
}

@media (max-width: 360px) {
  .esc-name  { font-size: 13px; }
  .esc-bubble { font-size: 12.5px; }
  .esc-hero h1 { font-size: 18px; }
}

/* ── STREAMING CURSOR ───────────────────────────────────── */
.esc-cursor {
  display: inline-block;
  width: 2px;
  background: var(--navy);
  margin-left: 2px;
  animation: cursorBlink 0.7s ease-in-out infinite;
  vertical-align: text-bottom;
  font-size: 0.9em;
}
@keyframes cursorBlink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}
.esc-streaming { min-height: 24px; }

/* ── CLEAR CHAT BUTTON ──────────────────────────────────── */
.esc-clear-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7); font-size: 14px;
  cursor: pointer; width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.esc-clear-btn:hover {
  background: rgba(233,30,140,0.25);
  border-color: rgba(233,30,140,0.5);
  color: #fff;
}

/* ── ACCESSIBILITY ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* ── RESIZE HANDLE ──────────────────────────────────────── */
.esc-resize-handle {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 18px;
  cursor: ns-resize;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  z-index: 10;
  border-radius: 8px 8px 0 0;
  transition: background 0.2s;
  padding: 3px 0;
}
.esc-resize-handle:hover,
.esc-resize-handle.dragging {
  background: rgba(27,58,107,0.08);
}
.esc-resize-handle span {
  display: block;
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: var(--gray-300);
  transition: background 0.2s;
}
.esc-resize-handle:hover span,
.esc-resize-handle.dragging span {
  background: var(--pink);
}

/* Make the window positioned for resize to work cleanly */
#escholar-window {
  position: relative;
}

/* ── FLOATING WINDOW (Moodle / external embed mode) ─────── */
#escholar-window.esc-floating {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 400px;
  height: 560px;
  z-index: 999998;
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(27,58,107,0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  transition: opacity 0.2s, transform 0.2s;
}
#escholar-window.esc-floating.hidden {
  display: none;
}
@media (max-width: 480px) {
  #escholar-window.esc-floating {
    width: calc(100vw - 16px);
    height: 80vh;
    bottom: 80px;
    right: 8px;
    left: 8px;
  }
}

/* ── SIGNUP PROMPT (logged-out state) ───────────────────── */
.esc-signup-prompt {
  background: linear-gradient(135deg, #f0f4ff 0%, #fce4f3 100%) !important;
  border: 1.5px solid var(--pink-light) !important;
}
.esc-signup-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 22px;
  background: var(--grad-pink);
  color: #fff !important;
  border-radius: 24px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none !important;
  transition: opacity 0.2s, transform 0.15s;
  box-shadow: 0 4px 14px rgba(233,30,140,0.3);
}
.esc-signup-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
.esc-login-link {
  color: var(--navy) !important;
  font-weight: 600;
  text-decoration: underline !important;
}
.esc-login-link:hover {
  color: var(--pink) !important;
}
.esc-input-locked textarea,
.esc-input-locked button {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
