/* ── SHFllm Chat Widget ────────────────────────────────────── */

#z80-bubble {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #33ff33;
    border: 2px solid #33ff3340;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3), 0 0 15px rgba(51,255,51,0.1);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
}
#z80-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 20px rgba(51,255,51,0.2);
}
#z80-bubble.active {
    opacity: 0;
    pointer-events: none;
}

/* ── Panel ── */

#z80-panel {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
    width: 360px;
    max-width: calc(100vw - 2rem);
    height: 420px;
    max-height: calc(100vh - 6rem);
    background: #0a0a0a;
    border: 1px solid #33ff3330;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 30px rgba(51,255,51,0.05);
    font-family: 'Fira Code', 'Courier New', monospace;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
    overflow: hidden;
}
#z80-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* ── Header ── */

.z80-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    background: #111;
    border-bottom: 1px solid #33ff3320;
    flex-shrink: 0;
}
.z80-title {
    color: #33ff33;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    font-weight: 500;
}
.z80-blink {
    animation: z80blink 1s step-end infinite;
}
@keyframes z80blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.z80-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}
.z80-close:hover { color: #33ff33; }

/* ── Messages ── */

.z80-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.z80-messages::-webkit-scrollbar { width: 4px; }
.z80-messages::-webkit-scrollbar-track { background: transparent; }
.z80-messages::-webkit-scrollbar-thumb { background: #33ff3330; border-radius: 2px; }

.z80-msg {
    font-size: 0.78rem;
    line-height: 1.5;
    word-break: break-word;
}
.z80-bot {
    color: #33ff33;
}
.z80-user {
    color: #888;
    padding-left: 0.5rem;
    border-left: 2px solid #333;
}
.z80-prompt {
    color: #33ff3380;
    margin-right: 0.3rem;
    user-select: none;
}

/* ── Input ── */

.z80-input-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #33ff3320;
    background: #0e0e0e;
    flex-shrink: 0;
}
.z80-caret {
    color: #33ff3380;
    font-size: 0.8rem;
    margin-right: 0.4rem;
    user-select: none;
}
#z80-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #ccc;
    font-family: inherit;
    font-size: 0.78rem;
    caret-color: #33ff33;
}
#z80-input::placeholder {
    color: #444;
}

/* ── Scanline effect ── */

#z80-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        transparent,
        transparent 2px,
        rgba(0,0,0,0.08) 2px,
        rgba(0,0,0,0.08) 4px
    );
    border-radius: 12px;
}

/* ── Mobile ── */

@media (max-width: 600px) {
    #z80-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 60vh;
        border-radius: 12px 12px 0 0;
        border-bottom: none;
    }
    #z80-bubble {
        bottom: 1rem;
        right: 1rem;
    }
}
