/* ===== AI TUTOR CHAT (Answer Sheet brand) ===== */
#ep-tutor-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 9999; font-family: var(--font-body); }

#ep-tutor-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--pai-ink); color: var(--pai-paper);
  border: none; cursor: pointer;
  box-shadow: 0 12px 28px -10px rgba(20,33,61,.55);
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s, background .18s;
  position: relative; z-index: 2;
}
#ep-tutor-btn:hover { transform: translateY(-2px); background: var(--pai-ink-2); }
#ep-tutor-btn::after { content: ''; position: absolute; top: 6px; right: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--pai-accent-bright); border: 2px solid var(--pai-ink); }
#ep-tutor-btn.is-open::after { display: none; }
#ep-tutor-btn .ep-ic-close { display: none; }
#ep-tutor-btn.is-open .ep-ic-chat  { display: none; }
#ep-tutor-btn.is-open .ep-ic-close { display: block; }

#ep-tutor-panel {
  position: absolute; bottom: 68px; right: 0;
  width: 370px; height: 540px;
  background: var(--pai-white);
  border: 1.5px solid var(--pai-line);
  border-radius: 18px;
  box-shadow: 0 30px 60px -24px rgba(20,33,61,.35);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: bottom right; animation: ep-tutor-in .2s ease;
}
#ep-tutor-panel[hidden] { display: none; }
@keyframes ep-tutor-in { from { opacity:0; transform:scale(.95) translateY(8px); } to { opacity:1; transform:none; } }

.ep-tutor-hdr { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 12px 16px; background: var(--pai-ink); color: var(--pai-paper); flex-shrink: 0; }
.ep-tutor-hdr-left { display: flex; align-items: center; gap: 10px; }
.ep-tutor-av { width: 36px; height: 36px; border-radius: 50%; background: rgba(251,250,246,.1); color: var(--pai-paper); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ep-tutor-hdr-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1.2; }
.ep-tutor-hdr-sub { color: #C9CFDB; font-size: .78rem; }
.ep-tutor-hdr-close { background: none; border: none; color: #C9CFDB; cursor: pointer; font-size: 22px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; }
.ep-tutor-hdr-close:hover { background: rgba(251,250,246,.1); color: #fff; }

#ep-tutor-msgs { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--pai-paper); }
#ep-tutor-msgs::-webkit-scrollbar { width: 4px; }
#ep-tutor-msgs::-webkit-scrollbar-thumb { background: var(--pai-line-strong); border-radius: 2px; }
.ep-tm { display: flex; }
.ep-tm--user { justify-content: flex-end; }
.ep-tm--assistant { justify-content: flex-start; }
.ep-tm-bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: .93rem; line-height: 1.65; word-break: break-word; }
.ep-tm--user .ep-tm-bubble { background: var(--pai-ink); color: var(--pai-paper); border-bottom-right-radius: 4px; }
.ep-tm--assistant .ep-tm-bubble { background: var(--pai-white); color: var(--pai-ink); border: 1.5px solid var(--pai-line); border-bottom-left-radius: 4px; }
.ep-tm--typing .ep-tm-bubble { display: flex; gap: 5px; align-items: center; padding: 13px 16px; }
.ep-tm--typing .ep-tm-bubble span { display: block; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--pai-ink); animation: ep-dot 1.2s ease-in-out infinite; }
.ep-tm--typing .ep-tm-bubble span:nth-child(2) { animation-delay: .2s; }
.ep-tm--typing .ep-tm-bubble span:nth-child(3) { animation-delay: .4s; }
@keyframes ep-dot { 0%,80%,100% { background: transparent; } 40% { background: var(--pai-accent); border-color: var(--pai-accent); } }
.ep-cursor { display: inline-block; width: 2px; height: 14px; background: var(--pai-accent); margin-left: 2px; vertical-align: text-bottom; animation: ep-cur .65s step-end infinite; }
@keyframes ep-cur { 50% { opacity:0; } }

.ep-tutor-action { padding: 2px 0 4px; }
.ep-tutor-action-btn { background: var(--pai-ink); color: var(--pai-paper); border: none; border-radius: var(--radius-full); padding: 8px 16px; font-size: .88rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.ep-tutor-action-btn:hover { background: var(--pai-ink-2); }

.ep-tutor-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1.5px solid var(--pai-line); background: var(--pai-white); flex-shrink: 0; }
#ep-tutor-field { flex: 1; background: var(--pai-paper); border: 1.5px solid var(--pai-line-strong); border-radius: 14px; color: var(--pai-ink); padding: 10px 14px; font-size: .95rem; font-family: inherit; resize: none; min-height: 44px; max-height: 120px; outline: none; line-height: 1.45; overflow-y: auto; }
#ep-tutor-field:focus { border-color: var(--pai-ink); }
#ep-tutor-field::placeholder { color: #7A8294; }
#ep-tutor-send { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; background: var(--pai-accent); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#ep-tutor-send:hover:not(:disabled) { background: var(--pai-accent-hover); }
#ep-tutor-send:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 480px) {
  #ep-tutor-panel { position: fixed; inset: auto 0 0 0; width: 100%; height: 78vh; border-radius: 20px 20px 0 0; bottom: 0; }
  #ep-tutor-wrap { bottom: 16px; right: 16px; }
}
@media (prefers-reduced-motion: reduce) { .ep-tm--typing .ep-tm-bubble span, .ep-cursor { animation: none !important; } }

/* ===== AI Performance Coach ===== */
#ep-coach-section { margin: 24px 0 32px; }
.ep-coach-card { background: var(--pai-white); border: 1.5px solid var(--pai-line); border-radius: 16px; padding: 20px 24px; }
.ep-coach-hdr { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ep-coach-icon { font-size: 1.2rem; }
.ep-coach-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--pai-ink); flex: 1; }
.ep-coach-badge { font-size: .72rem; font-weight: 700; background: var(--pai-ink-tint); color: var(--pai-ink); padding: 3px 10px; border-radius: var(--radius-full); }
.ep-coach-body { color: var(--pai-ink); font-size: .98rem; line-height: 1.75; min-height: 48px; }
.ep-coach-loading { display: flex; flex-direction: column; gap: 10px; }
.ep-coach-sk { height: 13px; border-radius: 6px; width: 100%; background: linear-gradient(90deg, var(--pai-inset) 25%, #E9E5DA 50%, var(--pai-inset) 75%); background-size: 200% 100%; animation: ep-sk-shimmer 1.4s infinite linear; }
.ep-coach-sk-sm { width: 78%; }
.ep-coach-sk-xs { width: 52%; }
@keyframes ep-sk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.ep-tutor-chip { background: var(--pai-white); border: 1.5px solid var(--pai-line-strong); color: var(--pai-ink); border-radius: var(--radius-full); padding: 6px 12px; min-height: 36px; font-family: inherit; font-size: .85rem; cursor: pointer; }
.ep-tutor-chip:hover { border-color: var(--pai-ink); }
.ep-tutor-err { color: var(--pai-danger); }
