/* NitroPlayer AI companion panel (owner: AI agent) */
.np-ai-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: .04em; line-height: 1;
  padding: 3px 5px; border-radius: 6px; margin-left: 6px; vertical-align: middle;
  background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe;
}

.npc {
  --npc-bg: var(--bg-card, #fff); --npc-border: var(--border, #e5e7eb);
  --npc-text: var(--text, #111827); --npc-dim: var(--text-dim, #6b7280); --npc-accent: var(--accent, #16a34a);
  background: var(--npc-bg); color: var(--npc-text); border: 1px solid var(--npc-border);
  border-radius: 16px; box-shadow: 0 4px 12px rgba(0,0,0,.05);
  display: flex; flex-direction: column; overflow: hidden; font-size: 14px; position: relative;
}
.npc--inline { margin-bottom: 16px; }
.npc--float {
  position: fixed; right: 16px; bottom: 16px; width: 320px; max-height: min(460px, 70vh); z-index: 900;
  box-shadow: 0 18px 40px rgba(0,0,0,.18);
}

.npc-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--npc-border); }
.npc-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; color: inherit; font: inherit; position: relative; }
.npc-avatar {
  --npc-c: #64748b;
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 21px; background: color-mix(in srgb, var(--npc-c) 18%, #fff); box-shadow: inset 0 0 0 2px var(--npc-c);
}
.npc-avatar--sm { width: 32px; height: 32px; flex-basis: 32px; font-size: 17px; }
.npc-meta { display: flex; flex-direction: column; min-width: 0; }
.npc-namewrap { display: flex; align-items: center; font-weight: 800; white-space: nowrap; }
.npc-name { overflow: hidden; text-overflow: ellipsis; }
.npc-record { font-size: 12px; color: var(--npc-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npc-dot { display: none; position: absolute; left: 29px; top: 0; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 2px solid var(--npc-bg); }
.npc--unread .npc-dot { display: block; }
.npc-actions { display: flex; gap: 4px; }
.npc-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--npc-border); background: var(--npc-bg); color: var(--npc-dim); cursor: pointer; font-size: 15px; line-height: 1; }
.npc-btn:hover { color: var(--npc-accent); border-color: var(--npc-accent); }

.npc-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.npc-log { overflow-y: auto; padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 6px; max-height: 220px; min-height: 64px; }
.npc--float .npc-log { max-height: none; flex: 1; }
.npc-msg { display: flex; }
.npc-msg--me { justify-content: flex-end; }
.npc-bubble { max-width: 85%; padding: 8px 11px; border-radius: 14px; line-height: 1.35; word-wrap: break-word; animation: npcIn .18s ease-out; }
.npc-msg--ai .npc-bubble { background: var(--bg-panel, #f1f5f9); border-bottom-left-radius: 4px; }
.npc-msg--me .npc-bubble { background: var(--npc-accent); color: #fff; border-bottom-right-radius: 4px; }
@keyframes npcIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.npc-typing { display: inline-flex; gap: 4px; padding: 6px 12px 8px; }
.npc-typing[hidden] { display: none; }
.npc-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--npc-dim); opacity: .5; animation: npcDot 1s infinite; }
.npc-typing span:nth-child(2) { animation-delay: .15s; }
.npc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes npcDot { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-4px); opacity: .9; } }

.npc-form { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--npc-border); }
.npc-input { flex: 1; min-width: 0; border: 1px solid var(--npc-border); border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 16px; outline: none; background: var(--npc-bg); color: inherit; }
@media (min-width: 641px) { .npc-input { font-size: 14px; } }
.npc-input:focus { border-color: var(--npc-accent); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
.npc-send { border: 0; border-radius: 999px; padding: 8px 14px; background: var(--npc-accent); color: #fff; font-weight: 700; cursor: pointer; }
.npc-note { font-size: 11px; color: var(--text-muted, #9ca3af); padding: 0 12px 8px; }

.npc-picker { border-bottom: 1px solid var(--npc-border); max-height: 260px; overflow-y: auto; padding: 6px; }
.npc-picker[hidden] { display: none; }
.npc-picker-title { font-size: 12px; font-weight: 700; color: var(--npc-dim); padding: 4px 6px 6px; }
.npc-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 6px; border: 0; background: none; border-radius: 10px; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.npc-opt:hover, .npc-opt.is-current { background: var(--bg-panel, #f1f5f9); }
.npc-opt-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.npc-opt-name { font-weight: 700; display: flex; align-items: center; }
.npc-opt-bio { font-size: 12px; color: var(--npc-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.npc-opt-fav { color: var(--gold, #f59e0b); }

/* minimized */
.npc--min .npc-body, .npc--min .npc-form, .npc--min .npc-note, .npc--min .npc-picker { display: none; }
.npc--min .npc-head { border-bottom: 0; }
.npc--float.npc--min { width: auto; max-width: 260px; border-radius: 999px; }
.npc--float.npc--min .npc-switch { display: none; }

.npc-peek {
  position: absolute; right: 0; bottom: calc(100% + 8px); max-width: 260px; padding: 8px 12px; border-radius: 14px;
  background: var(--npc-bg); border: 1px solid var(--npc-border); box-shadow: 0 8px 20px rgba(0,0,0,.12); cursor: pointer; font-size: 13px; line-height: 1.35;
}
.npc-peek[hidden] { display: none; }
.npc--inline .npc-peek { position: static; margin: 0 10px 10px; box-shadow: none; }
.npc--float { overflow: visible; }
.npc--float .npc-body { overflow: hidden; }

/* mobile: floating panel becomes a bottom sheet */
@media (max-width: 640px) {
  .npc--float { left: 0; right: 0; bottom: 0; width: auto; max-height: 60vh; border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .npc--float.npc--min { left: auto; right: 12px; bottom: 12px; border-radius: 999px; padding-bottom: 0; }
  .npc--float .npc-peek { right: 0; max-width: calc(100vw - 24px); }
}

@media (prefers-reduced-motion: reduce) { .npc-bubble, .npc-typing span { animation: none; } }
.npc-plink { color: inherit; text-decoration: underline; }
